$findfile » History » Version 4
Per Amundsen, 05/24/2018 10:11 AM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | *$findfile(dir,wildcard,N,[depth],[@window|command])* |
||
4 | |||
5 | 4 | Per Amundsen | Searches the specified directory and its subdirectories for the Nth filename matching the [[Scripting_Wildcards|wildcard]] file specification and returns the full path and filename if it is found. |
6 | 1 | Per Amundsen | |
7 | 3 | Per Amundsen | _If [[/halt]] is used in the [command], the search is halted instead of the entire script._ |
8 | |||
9 | 1 | Per Amundsen | *Parameters* |
10 | |||
11 | dir - The directory to search. |
||
12 | 4 | Per Amundsen | wildcard - [[Scripting_Wildcards|Wildcard]] to search for. |
13 | 1 | Per Amundsen | N - If N = 0, number of files, otherwise the Nth filename. |
14 | [depth] - Maximum folder depth. (optional) |
||
15 | [@window|command] - Custom window name to fill with the result or a command to run on each result. (optional) |
||
16 | |||
17 | *Properties* |
||
18 | |||
19 | .shortfn - Return the path in a [[$shortfn|shortfn]] format. |
||
20 | |||
21 | *Example* |
||
22 | |||
23 | <pre> |
||
24 | ; Print number of filenames found in $adiircdir. |
||
25 | 2 | Per Amundsen | //echo -ag $findfile($adiircdir,*.*,0) |
26 | 1 | Per Amundsen | |
27 | 2 | Per Amundsen | ; Print the 1st filename found. |
28 | //echo -ag $findfile($adiircdir,*.*,1) |
||
29 | |||
30 | 1 | Per Amundsen | ; Print all filenames in $adiircdir, when using the command parameter, $1- will hold the path. |
31 | //noop $findfile($adiircdir,*.*,0,echo -ag $1-) |
||
32 | |||
33 | </pre> |