Application icon

Delete Files and Folders

Warning: This statement is extremely dangerous!

This function permanently deletes files and/or folders. Any item can be deleted as long as you have the required permission. This includes audio files and files that you really should not be deleting

The text field may contain any of the escape sequences described in Escape Sequences. The text field is list aware. After escaping the field, it is decomposed into separate items delimited by newline (\n) or default list delimiter (\~) characters. Every item in the resolved list must be an absolute (/) or relative to the home folder (~/) file or folder path. Leading and trailing spaces are ignored in each list element.

The text field can be displayed in a multi-line editor by clicking on the control to the right of the field. \n sequences are changed to newline characters when displayed and changed back to \n sequences after editing.

Regardless of the execution mode, the function is only executed once.

The action test state is set to true if all specified items were deleted. If at least one item was not deleted, or there were no items, the action test state will be set to false.

Examples:

Delete Files and Folders in "\?do/test.txt \n /Volumes/Share/folder1"
Set named variable 'Stuff to Delete' to "\?do/test.txt \n /Volumes/Share/folder1"
Delete Files and Folders in "\<Stuff to Delete>"
Delete Files and Folders in "\?do/test.txt"

The first Delete Files and Folders statement deletes a file named test.txt in the Documents folder (\?do inserts a path to the Documents folder) and a folder at /Volumes/Share/folder1.

The second Delete Files and Folders statement is functionally identical to the first. The list is specified in a named variable.

The third Delete Files and Folders statement deletes only a single file as no list separators are present.


Note that the Write Text File statement can be used to delete a file if the content to be written is empty.

Be careful with this statement.