Move To Trash |
Moves a file or folder to the trash bin (recycle bin).
Syntax
Move To Trash [ Select ; Result (error) ; File or Folder Path ]
Options
| Select entire contents | replaces the entire 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 |
| File or Folder Path | the path to the file or folder you want to move to the trash |
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 item was moved to the trash |
| $$-43 | fnfErr | Source file or folder was not found |
| $$-1426 | errFSOperationNotSupported | This kind of item can’t be moved to the trash |
| $$-4414 | kErrVolumeHasNoTrash | This volume does not support a trash |
Other errors may be returned.
Originated in
Troi File Plug-in 18.0
Compatibility
FileMaker Pro 19 to FileMaker Pro 26
Considerations
The file or folder is not deleted but is moved to the trash. The items will be deleted when the user empties the trash.
On Windows the Trash is called Recycle Bin. On macOS the trash can also be called Bin.
You can’t move a volume (hard disk) to the trash, in this case the function returns error code $$-1426 (errFSOperationNotSupported).
Quite a few external volumes or network disks don’t support moving items into the trash. In this case, if you try to move a file or folder into the trash, the plug-in will return error code $$-4414 (kErrVolumeHasNoTrash). You can then opt for deleting the item directly, with the TrFile_DeleteFile or TrFile_DeleteFolder function.
Example
Move To Trash [ Select ; $ErrorCode ; "Mac HD:Users:brad:Old Folder" ]
This will move the folder Old Folder (and its contents) to the trash.
Example 2
Set Variable[ $SourceFile ; "C:\Users\bill\Desktop\Work.Doc" ]
Move To Trash [ Select ; $ErrorCode ; $SourceFile ]
This will move the file Work.Doc to the trash. This file will be deleted if the trash is emptied.
Used in example file
FileManipulation.fmp12
Related script steps
| Delete File |
| Delete Folder |
Related function
| TrFile_MoveToTrash |
Related topics
Troi File Plug-in online help (overview)