Skip to main content

Delete file (script step reference)

Troi File Plug-in for FileMaker Pro

Delete file

Deletes the file indicated by the file path

SyntaxScript step badge

Delete file [ Select ; Result (error) ; filePath ]

Options

Select entire contents replaces the contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Result (error) an error code
filePath the path to the file to delete

Returned Result

Data type returned

Error code

Result

The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

0 no error The file was deleted
$$-43 fnfErr The file was not found
$$-47 fBsyErr The file is in use
$$-1 genericErr The file could not be deleted

Other errors may be returned.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 16 to FileMaker Pro 2023

Considerations

WARNING: The file is not moved to the Trash, but deleted completely. This can not be undone!
See also the Dial_Dialog function (of the Troi Dialog plug-in) or use the Show Message script step if you want to warn the user.

You can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.

This script step was renamed in version 12.1 from Delete File to Delete file (note the lower case f), making its name different from the FileMaker native Delete File step. This ensures that when you copy and paste script steps the correct step is pasted.

Example

Assume your C disk already contains a file “TestFile.xls”. We assume that a global field gErrorCode is defined. Create the following script:

Delete file [ Select ; gErrorCode ; "C:\TestFile.xls" ]

This script will delete the file “TestFile.xls”. On macOS the path will be of the form “Mac HD:TestFile.xls”.

Example 2

We assume that in your FileMaker file the following fields are defined:

  gErrorCode		Global, number
  gFilePath		Global, text

gFilePath should contain the path to an existing file which you want to delete, for example “D:\Logs\Log01.TXT” (Windows) or “Mac HD:Logs:Log 1” (Mac). In a script add the following script step:

Delete file [ Select ; gErrorCode ;  gFilePath ]

This will delete the file from the disk.

Related script stepsScript step badge

Create File
Show Select File Dialog

Related functionFunction badge

TrFile_DeleteFile

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 16 to 2023 –> Delete file (filep7213) 2023-0601 16:21:39