Reference > Script steps reference > Files script steps > Delete File
 

Delete File

Deletes a file.

See also 

Options 

Target file is the path of the file to delete. See Creating file paths.

Compatibility 

 

Product 

Supported 

FileMaker Pro Advanced 

Yes 

FileMaker Go 

Yes 

FileMaker WebDirect 

No 

FileMaker Server 

Yes 

FileMaker Cloud for AWS 

Yes 

FileMaker Data API 

Yes 

Custom Web Publishing 

Yes 

Runtime solution 

No 

Originated in 

FileMaker Pro 18.0 Advanced

Example 1 

Deletes the change.log file.

Delete File [ Target file: "change.log" ]

Example 2 

Deletes the change.log file. If the file doesn't exist or another error occurs, the script displays a custom error message.

Set Error Capture [ On ]
Set Variable [ $file ; Value: "change.log" ]
Delete File [ Target file: $file ]
If [ Get ( LastError ) > 0 ]
If [ Get ( LastError ) = 100 ]
Set Variable [ $errorMessage ; Value: "The file doesn't exist." ]
Else
Set Variable [ $errorMessage ; Value: "Error: " & Get ( LastError ) & ¶ & "The file was not deleted." ]
End If
Show Custom Dialog [ $errorMessage ]
Exit Script [ Text Result: ]
End If
Show Custom Dialog [ "The file was deleted." ]

Related topics 

Create Data File script step

Rename File script step

Script steps reference (alphabetical list)

Script steps reference (category list)