Collapse
CollapsingX
  • - or -

DeleteFiles step overview


The DeleteFiles step allows you to delete specified files. This is particularly useful when archiving images on a drive with limited space (for example, a Matrox smart camera).

To delete a single file, specify its full path in the File List input in the Configuration pane. For information on specifying a file path, see the Specifying a path section in Appendix A: Expression syntax.

To delete multiple files, you must specify the full path of each file in an array of strings. For example, {["C:\\text.txt", "C:\\image.png"]} would delete the text.txt file and the image.png file from the C:\ folder of your runtime platform. You can use the LISTFILES function to quickly produce an array for this purpose.

Consider the following examples using the LISTFILES function:

Files to delete

Expression

All files in the C:\Tabula Rasa\ folder.

{LISTFILES("C:\\Tabula Rasa\\")}

All PNG files in the TempImages subfolder of the DA Documents folder.

{LISTFILES(CONCAT(PATH("DA Documents"),"\\TempImages"), "*.PNG")}

All files older than 24 hours in the SavedImages subfolder of the DA Documents folder.

{LISTFILES(CONCAT(PATH("DA Documents"),"\\SavedImages"), "*", ExceedingAge, 60*60*24)}

The oldest files in the SavedImages subfolder of the DA Documents folder, except for 200 Mbytes of the most recent files.

{LISTFILES(CONCAT(PATH("DA Documents"),"\\SavedImages"), "*", SortByTime | ExceedingCumulativeSize, 200)}

The result array from the LISTFILES function cannot be used with the DeleteFiles step if you select the Shortnames or Folders options.

Deleting folders

The DeleteFiles step cannot be used to delete folders directly. If you specify the full path of a folder, the DeleteFiles step will take no action. However, if the Delete Empty Folders option is selected when you specify a file(s), the DeleteFiles step will check whether or not the folder which contained each file is empty (contains no files or folders) immediately after the file is deleted. If the folder is empty, it will also be deleted. Files are deleted in the order that they appear in the array, meaning that the order of the file paths in the array can affect which folders are deleted.

This process is not recursive. The DeleteFiles step will not delete a folder as a result of deleting another folder.