List file |
Author: |
Message: |
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: List file
Hi.
Oh cool!
I didn't no what FileName contained.
I now how to send a message, but if i want to send all the files in one message with a carriage return after every file, how do i fix that?
Maybe it's a god idea to tell you what the plan for the script is.
The meaning is to show contacts what there is in a folder, for example in a folder with music.
|
|
08-22-2006 07:29 PM |
|
|
KnRd_WC
Junior Member
Florian PAQUET
Posts: 74 Reputation: 1
35 / /
Joined: Aug 2006
|
RE: List file
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,ChatWnd); // You have to send the ChatWnd value
return "";
}
}
function ListDirectory(Directory,Wnd) // 'Wnd' >> the message will be send to this window
{
f = fso.GetFolder(Directory);
var f1 = new Enumerator(f.files);
LIST="Directory content : "+Directory+"\n\n" // "\n" = Return
for (; !f1.atEnd(); f1.moveNext()) {
FileName = f1.item();
LIST+=" "+FileName+"\n" // add a tabulation, the file name and "\n"
}
Wnd.SendMessage(LIST); // when finished, send the message to the chat window (that's why you have to send 'ChatWnd' to the ListDirectory() function
}
function OnGetScriptCommands ()
{
commands="<ScriptCommands>";
commands+="<Command>";
commands+="<Name>list</Name>";
commands+="<Description>List directory</Description>";
commands+="</Command>";
commands+="</ScriptCommands>";
return commands;
}
Wow, Am I understandable ?
NOTE : The length of the message which will be sent is limited !!! ('cause of the MSN restrictions)
Edit : I know, this code can be optimized, but I wanted to do something easy and understandable, for example :
code: Dir=Message.substr(6,Message.length-6);
Dir=Dir.replace(/\\/gi,'\\\\');
ListDirectory(Dir,ChatWnd);
>>>>>
code: ListDirectory(Message.substr(6,Message.length-6).replace(/\\/gi,'\\\\'),ChatWnd);
or
code: FileName = f1.item();
LIST+=" "+FileName+"\n"
>>>>>
code: LIST+=" "+f1.item()+"\n";
This post was edited on 08-23-2006 at 11:22 AM by KnRd_WC.
|
|
08-22-2006 07:42 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: List file
Hi.
Og thanks!! I can't thanks enough!!
It's [b]lovely[/k] that people would helps!!
|
|
08-23-2006 11:06 AM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: List file
Hi.
Oh, i'm sorry. I don't want to abuse you, but..
I tried to delete the path before the filename, but it doesn't work.
I tried this:
code: Filnavn = Enum.item();
VisFilnavn = Filnavn.replace(/Directory/g,"");
|
|
08-23-2006 11:38 AM |
|
|
KnRd_WC
Junior Member
Florian PAQUET
Posts: 74 Reputation: 1
35 / /
Joined: Aug 2006
|
RE: List file
Erf... I'm sorry too... I can't find a way to remove the directory name...
I tried that :
code: FileName=FileName.substr(Directory.length,FileName.length-Directory.length);
Unsuccessfully...
And, I tried that too, just for testing :
code: FileName=FileName.replace(/c/gi,"a");
Unsuccessfully too. It seems it's impossible to use these functions on the 'Enum.item()' value. Is it a 'special' string ?
Please help, i'm going to learn something too
Note : In my code : 'FileName=f1.item()'
----------------------------------------------
EDIT: LOL !!!!
Just use .replace() in the last string !!! 'LIST' :
code: repl = new RegExp("("+Directory+")","gi");
Wnd.SendMessage(LIST.replace(repl,""));
Lol, just 5 minutes to find the solution
This post was edited on 08-23-2006 at 12:52 PM by KnRd_WC.
|
|
08-23-2006 12:39 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: List file
Hi.
I have changed the variabel names to danish words
I doesn't work. It shows the path
code: function ListDirectory(Directory,Wnd)
{
Hent = Info.GetFolder(Directory);
var Enum = new Enumerator(Hent.files);
Liste = "Sti: " + Directory + "\n\n"
for (; !Enum.atEnd(); Enum.moveNext())
{
Filnavn = Enum.item();
Liste += Filnavn + "\n"
}
FjernSti = new RegExp("("+Directory+")","gi");
Wnd.SendMessage(Liste.replace(FjernSti,""));
}
|
|
08-23-2006 12:52 PM |
|
|
KnRd_WC
Junior Member
Florian PAQUET
Posts: 74 Reputation: 1
35 / /
Joined: Aug 2006
|
RE: List file
Really ?? I tried with your function, and it works fine....
quote: Sti: \ <-- Maybe you want to remove that ??? (If you want to keep the path name here, see the function bottom)
AUTOEXEC.BAT
BOOT.BKK
boot.ini
Bootfont.bin
CONFIG.SYS
IO.SYS
MSDOS.SYS
NTDETECT.COM
ntldr
pagefile.sys
sqmnoopt00.sqm
To keep the path name "Sti : C:\", for example :
code: function ListDirectory(Directory,Wnd)
{
Hent = Info.GetFolder(Directory);
var Enum = new Enumerator(Hent.files);
Liste=""
for (; !Enum.atEnd(); Enum.moveNext())
{
Filnavn = Enum.item();
Liste += Filnavn + "\n"
}
FjernSti = new RegExp("("+Directory+")","gi");
Wnd.SendMessage("Sti: " + Directory.replace(/\\\\/gi,'\\')+ "\n\n"+Liste.replace(FjernSti,""));
}
This post was edited on 08-23-2006 at 01:03 PM by KnRd_WC.
|
|
08-23-2006 12:57 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: List file
Hi.
That's wierd!
The code you show me there returns this:
[k]Sti: C:\Documents and Settings\Basse\Dokumenter\Billeder
C:\Documents and Settings\Basse\Dokumenter\Billeder\avatar.gif[/k]
The meaning is to return this:
[k]Sti: C:\Documents and Settings\Basse\Dokumenter\Billeder
avatar.gif[/k]
|
|
08-23-2006 01:05 PM |
|
|
KnRd_WC
Junior Member
Florian PAQUET
Posts: 74 Reputation: 1
35 / /
Joined: Aug 2006
|
RE: List file
Yeah, that's really strange.... The script works fine for me....
Maybe you can try with my code :
code: Info=new ActiveXObject("Scripting.FileSystemObject")
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Message.substr(0,5)=="/list") {
ListDirectory(Message.substr(6,Message.length-6).replace(/\\/gi,'\\\\'),ChatWnd);
return "";
}
}
function ListDirectory(Directory,Wnd)
{
Hent = Info.GetFolder(Directory);
var Enum = new Enumerator(Hent.files);
Liste=""
for (; !Enum.atEnd(); Enum.moveNext())
{
Filnavn = Enum.item();
Liste += Filnavn + "\n"
}
FjernSti = new RegExp("("+Directory+")","gi");
Wnd.SendMessage("Sti: " + Directory.replace(/\\\\/gi,'\\')+ "\n\n"+Liste.replace(FjernSti,""));
}
function OnGetScriptCommands ()
{
commands="<ScriptCommands>";
commands+="<Command>";
commands+="<Name>list</Name>";
commands+="<Description>List directory</Description>";
commands+="</Command>";
commands+="</ScriptCommands>";
return commands;
}
And try : /list C:\
This post was edited on 08-23-2006 at 01:13 PM by KnRd_WC.
|
|
08-23-2006 01:11 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: List file
Hi!
That works!!
But, i'm a perfectionist and i would like to delete the "\" before the filename
That sounds simple, but.. You use commands i don't know, but i'm learning when i see codes
Ohh.. I'm so sorry to be troublesome
This post was edited on 08-23-2006 at 01:21 PM by SnuZZer.
|
|
08-23-2006 01:19 PM |
|
|
Pages: (3):
« First
«
1
[ 2 ]
3
»
Last »
|
|