mIRC Home    About    Download    Register    News    Help

Print Thread
On Text Sending Random Files In A Folder #91105 20/07/04 09:13 AM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
How do i write a on text script whereby on text i will send a random file in a specific folder?

Re: On Text Sending Random Files In A Folder #91106 20/07/04 10:30 AM
Joined: Apr 2004
Posts: 45
V
Venoman Offline
Ameglian cow
Offline
Ameglian cow
V
Joined: Apr 2004
Posts: 45
Code:
on *:text:[color:red]texthere[/color]:[color:red]#[/color]: {
  var %num = $rand(1,[color:red]20[/color])
  var %file = $+(",$findfile("[color:red]c:\path\to\folder\[/color]",*.*,%num),")
  dcc send $nick %file
}


You need to replace the parts in red:
for texthere, replace that with the key word you want to respond to.
for #, right now it means it responds to the texthere text in any channel window. You can change it to ? for PM windows, or #blah for a specific channel, et cetera. See /help on text for more info.
20 should be the total number of files you have in the folder, and c:\path\to\folder\ should point to the actual folder you're using. I haven't tested this, but no reason it shouldn't work.

-Venoman

Re: On Text Sending Random Files In A Folder #91107 20/07/04 10:55 AM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
Thank you.

Re: On Text Sending Random Files In A Folder #91108 20/07/04 11:03 AM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
there seems to be a problem..

* /dcc: insufficient parameters (line 4, script3.ini)

variable %file is not set automatically

Re: On Text Sending Random Files In A Folder #91109 20/07/04 12:30 PM
Joined: Apr 2004
Posts: 45
V
Venoman Offline
Ameglian cow
Offline
Ameglian cow
V
Joined: Apr 2004
Posts: 45
you'll get that error sometimes if you replaced the number 20 with a number higher than the total # of files in the folder. Also make sure you specify the whole path to the folder correctly.

-Venoman

Re: On Text Sending Random Files In A Folder #91110 20/07/04 05:49 PM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327

  • on *:text:texthere:#: {
    var %num = $rand(1,$findfile([color:red]c:\path\to\folder,*.*,0)[/color])
    var %file = $+(",$findfile(c:\path\to\folder\,*.*,%num),")
    dcc send $nick %file
    }


Change the parts in red.


New username: hixxy
Re: On Text Sending Random Files In A Folder #91111 20/07/04 05:51 PM
Joined: Apr 2004
Posts: 45
V
Venoman Offline
Ameglian cow
Offline
Ameglian cow
V
Joined: Apr 2004
Posts: 45
ah, knew there was a way to list the total # of files in a folder, just couldn't think of it smile

-Venoman

Re: On Text Sending Random Files In A Folder #91112 20/07/04 10:51 PM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
i still get the invalid parameters, this is how it looks after i have changed everything.

Code:
 on *:text:@[JP]Rina-Uchiyama:#abcd:{ 
  var %num = $rand(1,$findfile(C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama,*.*,0)) 
  var %file = $+(",$findfile(C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama,*.*,%num),") 
  dcc send $nick %file
}  

Re: On Text Sending Random Files In A Folder #91113 20/07/04 11:12 PM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Not exactly, sure why your getting invalid parameters.. try adding some checks:

On *:text:@trigger*:[color:red]#Channel
:{
var %dir = [color:red]C:\directory here\

if (!$isdir(%dir)) { echo -a ERROR: Folder doesnt exist. }
else {
var %num = $rand(1,$findfile(%dir,*.*,0))
var %file = $+(",$findfile(%dir,*.*,%num),")
if (!$isfile(%file)) { echo -a ERROR: File doesnt exist. }
else { dcc send $nick %file }
}
}
[/color]

Eamonn.

Re: On Text Sending Random Files In A Folder #91114 20/07/04 11:57 PM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
File doesnt exist. =\

Re: On Text Sending Random Files In A Folder #91115 21/07/04 12:05 AM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Werid, try typing it from a command line:

//echo -> $findfile(C:\DIR\,*,$rand(1,$findfile(C:\DIR\,*,0)))

Replacing, C:\DIR\

Eamonn.

Re: On Text Sending Random Files In A Folder #91116 21/07/04 12:30 AM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
echo results.

-> C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama\032.jpg

Re: On Text Sending Random Files In A Folder #91117 21/07/04 01:29 PM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
upz

Re: On Text Sending Random Files In A Folder #91118 22/07/04 09:20 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Problem may be that the file (or a dir in the path) has two consecutive spaces.

Re: On Text Sending Random Files In A Folder #91119 23/07/04 05:00 AM
Joined: Jul 2004
Posts: 12
I
icybergie Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Jul 2004
Posts: 12
they are all picture files. none of them has any spaces =\~

As for the folder, there are only 1 space

Re: On Text Sending Random Files In A Folder #91120 25/07/04 04:51 PM
Joined: Apr 2004
Posts: 45
V
Venoman Offline
Ameglian cow
Offline
Ameglian cow
V
Joined: Apr 2004
Posts: 45
no no no. always ALWAYS enclose paths to files and folders in quotes. I suppose I should have done that in my example, so that's my fault. your path has spaces, which won't actually return the full path when put to use, unless you put it in quotes.

Code:
on *:text:@[JP]Rina-Uchiyama:#abcd:{ 
  var %num = $rand(1,$findfile("C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama",*.*,0)) 
  var %file = $+(",$findfile("C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama",*.*,%num),") 
  dcc send $nick %file
}


there ya go.

-Venoman