Project

General

Profile

$findfile » History » Version 5

Per Amundsen, 02/22/2023 04:45 PM

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 5 Per Amundsen
table(ktable).
12
|*Parameter*|*Description*|
13
| dir | The directory to search. |
14
| wildcard | [[Scripting_Wildcards<notextile>|</notextile>Wildcard]] to search for. |
15
| N | If N = 0, number of files, otherwise the Nth filename. |
16
| [depth] | Maximum folder depth. (optional) |
17
| [@window<notextile>|</notextile>command] | Custom window name to fill with the result or a command to run on each result. (optional) |
18 1 Per Amundsen
19
*Properties*
20
21 5 Per Amundsen
table(ktable).
22
|*Property*|*Description*|
23
| .shortfn | Return the path in a [[$shortfn<notextile>|</notextile>shortfn]] format. |
24 1 Per Amundsen
25
*Example*
26
27
<pre>
28
; Print number of filenames found in $adiircdir.
29 2 Per Amundsen
//echo -ag $findfile($adiircdir,*.*,0)
30 1 Per Amundsen
31 2 Per Amundsen
; Print the 1st filename found.
32
//echo -ag $findfile($adiircdir,*.*,1)
33
34 1 Per Amundsen
; Print all filenames in $adiircdir, when using the command parameter, $1- will hold the path.
35
//noop $findfile($adiircdir,*.*,0,echo -ag $1-)
36
37
</pre>