TrFile_Search (function reference)

By May 1, 2017May 20th, 2020Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro


Search a folder (or volume) for a file or folder (directory).

SyntaxFunction badge

TrFile_Search ( switches ; folderPath ; searchName )


switchesthese determine the items that are listed
folderPaththe path to the folder (or volume) in which to search
searchNamethe (part of the) filename or foldername you want to find


switches can be one or more of the following:

-Filessearch for files
-Folderssearch for folders
-Exactnamethe filename must exactly match the searchname
-Showaliasessearch also aliases (shortcuts)
-Showshortcutssearch also aliases (shortcuts) (you can use the one you like)
-Showinvisiblessearch also invisible files and folders
-Shortnamesreturn shortened names, less than 31 characters long (for classic macOS)
-ReturnAtEndadd an extra return character after the last found item in the list
-Exhaustivesearch by enumerating the folders, might be slow for folders with lots of items
-UseSpotlight(macOS only) search for files and folders using Spotlight
-FileMakerPathFormatreturn the result as fully qualified FileMaker formatted paths

Returned Result

Data type returned



a list of paths of the found items separated by returns.

Originated in

Troi File Plug-in 1.2


FileMaker Pro 15 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" ) ]

Example 2

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.

Example 3

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:


Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 15 to 19 –> TrFile_Search (filep4270) 2020-0520 18:04:55