Skip to content

TSTool / Command / RemoveFolder


Overview

The RemoveFolder command removes a folder and its contained files and folders. Common uses for the command are:

  • remove workflow output files before regenerating the results so that no old files might be mistaken for current results
  • remove temporary and working files that are not needed at the end of a workflow
  • remove folders during software testing to ensure that commands are generating output as expected

A failure will be generated if the folder exists and cannot be removed (e.g., due to file permissions or because a file in the folder is being used by another process).

Even read-only files may be removed by this command, depending on how the operating system and computer environment handle access permissions, for example if TSTool is run as a "sudo" user on Linux.

Because removing a folder is a destructive process, it is recommended that TSTool is run as a normal user without administrative privileges. The MinDepth parameter provides a level of protection to make sure that the desired level of subfolder is removed.

See the CreateFolder command to create a folder.

Command Editor

The command is available in the following TSTool menu:

  • Commands / General - File Handling

The following dialog is used to edit the command and illustrates the command syntax.

RemoveFolder command editor

RemoveFolder Command Editor (see full-size image)

Command Syntax

The command syntax is as follows:

RemoveFolder(Parameter="Value",...)

Command Parameters

Parameter                           Description Default          
Folder
required
The name of the folder to delete. Can be specified using ${Property}. None - must be specified.
MinDepth The minimum folder depth that is required, which is used to guard against accidentally deleting high-level folders. For example /folder1/folder2/file.txt has a folder depth of 2. If the minimum depth is not met, the command will fail. 3
IfNotFound Indicate an action if the folder is not found:
  • Ignore - ignore the missing folder and do not warn
  • Warn - generate a warning message
  • Fail - generate a failure message
Warn

Examples

See the automated tests.

Troubleshooting

See the main TSTool Troubleshooting documentation.

See Also