Lists what is inside a folder (directory). It will return all files and/or folders, depending on the switches given.
TrFile_ListFolder( switches ; folderPath )
|switches||these determine the items that are listed|
|folderPath||the path to the folder to list|
switches can be one or more of the following:
|-Files||list all files in this folder|
|-Folders||list all folders (subdirectories) in this folder|
|-Showaliases||list all aliases (shortcuts) in this folder|
|-Showshortcuts||list all aliases (shortcuts) in this folder (you can use the one you like)|
|-Showinvisibles||list all invisible files and folders|
|-Showpointdirs||Windows: list also the directory . (current dir) and .. (parent dir)|
|-Showpointdirs||Mac OS: this switch is ignored|
|-Longnames||(default) Mac OS: return long names, possibly more than 31 characters|
|-Shortnames||Mac OS: return shortened names, less than 31 characters long|
You can also add these switches:
|-Recursive||get the list of files and folders and all the subfolders of the folder you are listing|
|-ShowPackageContents||(Mac OS) also list the contents of a package folder (used in combination with -Recursive)|
|-DontEncodeSlash||(Mac OS) don’t encode slashes in name with %2F (in combination with -Recursive)|
|-ReturnAtEnd||add an extra return character after the last found item in the list|
|-AddFolderSuffix||this will add a trailing slash to folders in the result, making them recognizable as folders|
Data type returned
folder list a list of names of the items separated by returns.
Troi File Plug-in 1.2
FileMaker Pro 13 to 17
You can recursively get the list of files and folders and all the subfolders of the folder you are listing. To enable this add the switch “-Recursive”. Note that files and folders in subfolders will be listed with the relative folderpath, with a slash as separator, for example “SubFolder1/filename.txt”.
Starting with v5.5 the switch “-Longnames” is the default, so you no longer need to specify it. If you want short names (on Mac OS X): 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, for longer names the file name will look like mygreatimagefilebuttoo#E11E.txt
You can use FileMaker styled paths, like “filewin:/C:/MyFiles/”.
Set Field [ result ; TrFile_ListFolder ( "-Files -Folders " ; "Mac HD:" ) ]
This will return a list of all files and folders on the hard disk “Mac HD”. Note that the order of the switches is not relevant. This might be returned:
On Windows an example usage is:
Set Field [ result ; TrFile_ListFolder ( "-Files -Showshortcuts" ; "C:\Data\" ) ]
This will return a list of all files and shortcuts on the hard disk “C:\Data\”.
We assume that in your FileMaker file the following fields are defined:
gFolderPath Global, text gFolderList Global, text
gFolderPath should contain the path to the folder, for example “D:\Logs\Data\” (Windows) or “Mac HD:Logs:Data:” (Mac OS). In a script add the following scriptstep:
Set Field [ gFolderList ; TrFile_ListFolder ( "-Files -Folders " ; gFolderPath ) ]
This will list the contents of the folder specified in the gFolderPath.