Difference between revisions of "$findfile"

From Scriptwiki
Jump to: navigation, search
m (added semi-colons)
m (added some examples)
Line 12: Line 12:
  
 
If you specify the ''command'' this command will be executed for each found file, where $1- is the filename.
 
If you specify the ''command'' this command will be executed for each found file, where $1- is the filename.
 +
 +
== 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.

Revision as of 19:44, 20 October 2007

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.

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.