Project

General

Profile

$finddir » History » Version 8

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

1 1 Per Amundsen
_Added in 1.9.0_
2
3
*$finddir(dir,wildcard,N,[depth],[@window|command])*
4
5 7 Per Amundsen
Searches the specified directory and its sub directories for the Nth directory name matching the [[Scripting_Wildcards|wildcard]] specification and returns the full path and directory if it is found.
6 1 Per Amundsen
7 6 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 8 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 directories, otherwise the Nth directory. |
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 4 Per Amundsen
*Properties*
20 1 Per Amundsen
21 8 Per Amundsen
table(ktable).
22
|*Property*|*Description*|
23
| .shortfn | Return the path in a [[$shortfn<notextile>|</notextile>shortfn]] format. |
24 2 Per Amundsen
25
*Example*
26
27
<pre>
28
; Print number of sub directories found in $adiircdir.
29 5 Per Amundsen
//echo -ag $finddir($adiircdir,*.*,0)
30 1 Per Amundsen
31
; Print the 1st directory found.
32 3 Per Amundsen
//echo -ag $finddir($adiircdir,*.*,1)
33 5 Per Amundsen
34
; Print all sub directories in $adiircdir, when using the command parameter, $1- will hold the path.
35
//noop $finddir($adiircdir,*.*,0,echo -ag $1-)
36 2 Per Amundsen
</pre>