What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » List file

Pages: (3): « First [ 1 ] 2 3 » Last »
List file
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. List file
Hi.
I'm from Denmark and my english isn't good.

I want to make a list of files in a folder. The users types a command (Example: /list) and after the command /list they type the folder they want to make a list of.

Is this possible?

- Simon
08-22-2006 02:08 PM
Profile E-Mail PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: List file
code:
   files = new Array();
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.GetFolder({folderpath}); //put folder path here with // instead of just /
   fc = new Enumerator(f.files);
   i = 0;
   for (; !fc.atEnd(); fc.moveNext())
   {
      files[i] = fc.item();
      i++;
   }

This will return the files within the folder in an array for you.

This post was edited on 08-22-2006 at 02:26 PM by markee.
[Image: markee.png]
08-22-2006 02:25 PM
Profile PM Find Quote Report
KnRd_WC
Junior Member
**

Avatar
Florian PAQUET

Posts: 74
Reputation: 1
35 / Male / Flag
Joined: Aug 2006
RE: List file
Hi SnuZZer,

code:
fso=new ActiveXObject("Scripting.FileSystemObject")

function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
    if (Message.substr(0,5)=="/list") {
        Dir=Message.substr(6,Message.length-6);
        Dir=Dir.replace(/\\/gi,'\\\\');
        ListDirectory(Dir);
        return "";
    }
}

function ListDirectory(Directory)
{
    f = fso.GetFolder(Directory);
    var f1 = new Enumerator(f.files);
    for (; !f1.atEnd(); f1.moveNext()) {
        FileName = f1.item(); // Here's the file name
    }
    // SubFolders
    //var f2=new Enumerator(f.subfolders);
     //for (; !f2.atEnd(); f2.moveNext()) {
    //    ListDirectory(f2.item()); 
     //}
}

function OnGetScriptCommands ()
{
    commands="<ScriptCommands>";
    commands+="<Command>";
    commands+="<Name>list</Name>";
    commands+="<Description>List directory</Description>";
    commands+="</Command>";
    commands+="</ScriptCommands>";
    return commands;
}
------------------------------
EDIT : Argh, I'm too slow !!! :D

This post was edited on 08-22-2006 at 02:31 PM by KnRd_WC.
08-22-2006 02:29 PM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: List file
quote:
Originally posted by markee
f = fso.GetFolder({folderpath}); //put folder path here with // instead of just /
Incorrect, paths would be used like this : C:\\my\\test
08-22-2006 03:07 PM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: List file
Hi.
KnRd_WC i've tried this:
code:
fso=new ActiveXObject("Scripting.FileSystemObject")

function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Message.substr(0,5)=="/list") {
Dir=Message.substr(6,Message.length-6);
Dir=Dir.replace(/\\/gi,'\\\\');
ListDirectory(Dir);
return "";
}
}

function ListDirectory(Directory)
{
f = fso.GetFolder(Directory);
var f1 = new Enumerator(f.files);
for (; !f1.atEnd(); f1.moveNext()) {
FileName = f1.item("C:\Documents and Settings\Basse\Dokumenter\Musik\Niarn - Antihelt"); // Here's the file name
}
// SubFolders
//var f2=new Enumerator(f.subfolders);
//for (; !f2.atEnd(); f2.moveNext()) {
// ListDirectory(f2.item());
//}
}

function OnGetScriptCommands ()
{
commands="<ScriptCommands>";
commands+="<Command>";
commands+="<Name>list</Name>";
commands+="<Description>List directory</Description>";
commands+="</Command>";
commands+="</ScriptCommands>";
return commands;
}

It says that the command doesn't exists :-/
08-22-2006 03:11 PM
Profile E-Mail PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: List file
quote:
Originally posted by SnuZZer
f1.item("C:\Documents and Settings\Basse\Dokumenter\Musik\Niarn - Antihelt");

why'd you add that there o.o
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
08-22-2006 03:13 PM
Profile PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: List file
quote:
Originally posted by KnRd_WC
FileName = f1.item(); // Here's the file name[/code]

What else? :-/
08-22-2006 03:16 PM
Profile E-Mail PM Web Find Quote Report
KnRd_WC
Junior Member
**

Avatar
Florian PAQUET

Posts: 74
Reputation: 1
35 / Male / Flag
Joined: Aug 2006
RE: List file
You don't have to add anything here ! :)
code:
FileName = f1.item();
'f1' is an enumerator which contain all files in the directory, so, with 'f1.moveNext()' you select the next entry and, with 'f1.item()' you get the text ! (I hope I'm comprehensible...)

'FileName' IS the file name !!! :S

If you want to list the directory content , type :
/list C:\Documents and Settings\Basse\Dokumenter\Musik\Niarn - Antihelt\ <-- don't forget this one !

And, for example you can try this :
code:
FileName = f1.item();
Debug.Trace(FileName);

;)

This post was edited on 08-22-2006 at 03:38 PM by KnRd_WC.
08-22-2006 03:33 PM
Profile PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: List file
Hi.
I'm sorry!
I really don't understand!
If i write /list C:\Documents and Settings\Basse\Dokumenter\Musik\Niarn - Antihelt\ in the chatwindow nothing happens.

Shell i change the script?

code:
fso=new ActiveXObject("Scripting.FileSystemObject")

function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Message.substr(0,5)=="/list") {
Dir=Message.substr(6,Message.length-6);
Dir=Dir.replace(/\\/gi,'\\\\');
ListDirectory(Dir);
return "";
}
}

function ListDirectory(Directory)
{
f = fso.GetFolder(Directory);
var f1 = new Enumerator(f.files);
for (; !f1.atEnd(); f1.moveNext()) {
FileName = f1.item(); // Here's the file name
}
// SubFolders
//var f2=new Enumerator(f.subfolders);
//for (; !f2.atEnd(); f2.moveNext()) {
// ListDirectory(f2.item());
//}
}

function OnGetScriptCommands ()
{
commands="<ScriptCommands>";
commands+="<Command>";
commands+="<Name>list</Name>";
commands+="<Description>List directory</Description>";
commands+="</Command>";
commands+="</ScriptCommands>";
return commands;
}
08-22-2006 06:54 PM
Profile E-Mail PM Web Find Quote Report
KnRd_WC
Junior Member
**

Avatar
Florian PAQUET

Posts: 74
Reputation: 1
35 / Male / Flag
Joined: Aug 2006
RE: List file
Hi SnuZZer,

Look at this:

code:
//...............
function ListDirectory(Directory)
{
f = fso.GetFolder(Directory);
var f1 = new Enumerator(f.files);
for (; !f1.atEnd(); f1.moveNext()) {
FileName = f1.item(); // GET the filename
// Here, you get the file name in the variable 'FileName', and, that's all !! If you want to display the filename, in a Toast, for example, you may use that :
MsgPlus.DisplayToast("List Directory",FileName);
}
// SubFolders (If you want to include sub-folders, un-comment (lol, english ?) these lines :
//var f2=new Enumerator(f.subfolders);
//for (; !f2.atEnd(); f2.moveNext()) {
// ListDirectory(f2.item());
//}
}
//...............
I'd like to explain to you how this function works, but that's very hard, I can't find the words to say that... :(

This post was edited on 08-22-2006 at 07:18 PM by KnRd_WC.
08-22-2006 07:13 PM
Profile PM Web Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On