$findfile

From Scriptwiki
Revision as of 19:00, 20 October 2007 by Vliedel (talk | contribs) (done?)

Jump to: navigation, search

Finds files in a specified directory.

 $findfile(dir,matchstring,N[,depth][,@window | command])

Returns the N'th matching filename, or when N=0 the number of matching filenames.

dir is the directory in which has to be searched.

matchstring is the string to match the filename. You can specify multiple searches at once, by seperating them with semi-colons.

depth is how many dirs deep have to be searched. If depth is 0 or 1, it will only search the specified dir without it's subdirs. In case you don't specify depth it will search all subdirs.

If you specify a custom window name @window which has a listbox, it will add the found files to the listbox.

If you specify the command this command will be executed for each found file, where $1- is the filename.

The $findfilen identifier returns the Nth matching filename that was last found. This identifier is local, it's only valid untill the script ends.

Examples

 echo -ag $findfile($mircdir,*.exe,2)

Echoes the second filename matching *.exe in your mIRC dir (for example mirc.exe).

 echo -ag $findfile(C:,*.txt,0,2)

Echoes the number of .txt files on C:\, 2 dirs deep (so C:\dir\ will be searched but C:\dir\dir2\file2.txt won't).

 window -l @logs
 noop $findfile($mircdir,*.log,0,@logs)

Opens a window @logs with listbox and adds all .log files in your mIRC dir to the listbox.

 noop $findfile($mircdir,*,0,echo -s File $findfilen $+ : $1-)

Echoes a numbered line for each found file in the mIRC dir.