Check for the existence of a file or folder.
TrFile_Exists ( switches ; filePath )
|switches||not used, reserved for future use. Leave blank or put "-Unused"|
|filePath||the path to the file for which you want to know if it exists|
Data type returned
The returned result is a boolean: the function returns 1 if the file or folder exists. If it does not exist or if an error occurs it will return 0.
Troi File Plug-in 3.1
FileMaker Pro 16 to 19
If the function returns 0 you should decide if it is necessary to check for errors, for example if a file is on a disk that is not mounted.
Set Field [ doesExists ; TrFile_Exists ( "-Unused" ; "C:\Test.txt" ) ]
This will return 1 if it exists.
We assume that in your FileMaker file the following field is defined:
gFilePath Global, text
gFilePath should contain the path to a file, for example “D:\Logs\L2000_01.TXT” (Windows) or “Mac HD:Logs:Log 2000_01” (Mac). In a script add the following script steps:
if [ TrFile_Exists ( "-Unused" ; gFilePath ) ] # ... do your stuff here else # ... do your error handling here.... endif
This will make it easy to handle existing files.
Used in example file
Troi File Plug-in online help (overview)