Delete Folder (script step reference)

By May 1, 2017 May 22nd, 2019 Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

Delete Folder

Deletes the folder indicated by the folderPath.

SyntaxScript step badge

Delete Folder [ Select ; Result (error) ; FolderPath ;
                Delete all subfolders ]

Options

Select entire contentsreplaces 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
FolderPaththe path to the folder to delete
Delete all subfoldersdelete all sub folders and also the contents of those folders

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:

0no errorthe folder was deleted
$$-1the user cancelled the action
$$-37bdNamErrbad name in the file system
$$-47fBsyErrfile is busy, can’t delete because the folder is not empty
$$-50paramErrparameter error, check if the supplied parameters are correct
$$-120dirNFErrdirectory not found, is not a directory or is a file

Other errors may be returned.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 16 to 18

Considerations

WARNING This is a powerful feature. Be careful what you do! Note also that the folder is not moved to the Trash, but deleted completely. This can not be undone!
See also 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 “filemac:/MacHD/folder/subfolder”.

Example

Assume your C disk already contains a folder “Test Directory”. We assume that a global number field gErrorCode is defined. Create the following script:

Delete Folder [ Select ; $ErrorCode ; "-Unused " ; " C:\Test Directory\" ]

This script will delete the folder “Test Directory”. On Mac OS the path will be of the form “Mac HD:Test Directory:”.

Example 2

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

  gErrorCode		Global, number
  gFolderPath		Global, text

gFolderPath should contain the path to an existing folder which you want to delete, for example “D:\Logs\” (Windows) or “Mac HD:Logs:” (Mac). In a script add the following scriptstep:

Delete Folder [ Select ; gErrorCode ;  gFolderPath ; Delete all subfolders ]

This will delete the folder from the disk, including contents, like files and folders. The user is always given a warning. If you don’t use ‘Delete all subfolders’ only empty folders are deleted.

Related script stepsScript step badge

Create Folder
Show Select Folder Dialog

Related functionFunction badge

TrFile_DeleteFolder

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 14 to 18 –> Delete Folder (filep7214) 2019-0522 16:35:02