Application icon

Trash Files and Folders

This function moves files and/or folders to the trash. Any item can be moved to the trash as long as you have the required permission and it is on a volume which supports the trash. This includes audio files.

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.

You can optionally choose to delete files if they cannot be moved to the trash. Warning: This option is extremely dangerous!.

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

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

This statement does not make the trash noise and Put Back is not available for moved files.

Examples:

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

The first Trash Files and Folders statement trashes 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 Trash Files and Folders statement is functionally identical to the first. The list is specified in a named variable.

The third Trash Files and Folders statement trashes 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.