Search a folder (or volume) for a file or folder (directory).
TrFile_Search ( switches ; folderPath ; searchName )
|switches||these determine the items that are listed|
|folderPath||the path to the folder (or volume) in which to search|
|searchName||the (part of the) filename or foldername you want to find|
switches can be one or more of the following:
|-Files||search for files|
|-Folders||search for folders|
|-Exactname||the filename must exactly match the searchname|
|-Showaliases||search also aliases (shortcuts)|
|-Showshortcuts||search also aliases (shortcuts) (you can use the one you like)|
|-Showinvisibles||search also invisible files and folders|
|-Shortnames||return shortened names, less than 31 characters long (for classic macOS)|
|-ReturnAtEnd||add an extra return character after the last found item in the list|
|-Exhaustive||search by enumerating the folders, might be slow for folders with lots of items|
|-UseSpotlight||(macOS only) search for files and folders using Spotlight|
|-FileMakerPathFormat||return the result as fully qualified FileMaker formatted paths|
Data type returned
a list of paths of the found items separated by returns.
Troi File Plug-in 1.2
FileMaker Pro 16 to 19
You can also specify a folder in which the search must be done, instead of searching the whole volume.
Note that the final path is also followed by a return!
You can search using Spotlight on macOS by adding the switch -useSpotlight. But note that Spotlight does not return all files, for example it omits hidden (invisible) files. Also Spotlight search will not work if a disk is not indexed yet. It is however quite fast.
Starting with v5.5 the switch “-Longnames” is the default, so you no longer need to specify it. If you want short names (on macOS): use the “-Shortnames” switch. Mac OS 9.x supported only names up to 31 characters, so with the “-Shortnames” switch the names will be shorter or equal than 31 characters, longer filenames will look like mygreatimagefilebuttoo#E11E.txt
Set Field [ result ; TrFile_Search ( "-files -folders" ; "HD:Users:Kes:" ; "readme" ) ]
This will return a list of all files and folders in folder “HD:Users:Kes:” with the name ‘readme’. Note that the order of the switches is not relevant. This might be returned:
HD:Users:Kes:Foto, film, geluid:Geluiden:Alert!!!:Readme¶
HD:Users:Kes:Programma’s:Beeld:GIFConverter 2.3.7 ƒ:README-registration¶
HD:Users:Kes:Programma’s:Beeld:MOVIES:OBJTOOL:README, Make QTVR Object¶
On Windows an example use is:
Set Field [ result ; TrFile_Search ( "-files -folders" ; "C:" ; "readme" ) ]
Set Variable [ $result ; TrFile_Search ( "-files -folders -invisibles" ; "HardDisk:" ; "readme" ) ]
This will return a list of all files and folders on the hard disk “HardDisk” with the name ‘readme’, including invisible files.
Set Variable [ $result ; TrFile_Search ( "-files -FileMakerPathFormat" ; "HardDisk:" ; "readme" ) ]
This will return a list of all files on the disk “HardDisk” with the name ‘readme’, The result will be a list of fully qualified FileMaker style formatted path, for example:
Used in example file