--- alias: user-guide-automation-task-filedrivers-emptydirectory tags: - automation tasks description: "This task deletes a specified directory path, attempting multiple times with delays" --- # Empty Directory ![Screenshot showing an empty directory with no files or subdirectories.](images/emptydirectory-lg.svg) When activated, the `empty directory` task empties a given directory. The directory `path` can be provided either by the input port or in the task settings. ![Screenshot showing an empty directory with a filename hint of "image23".](./images/image23.png) ## Inputs | Name | | Description | |----------------------|-----------|--------------------------------------------------------------------| | path | `String` | Directory path | | attempts | `Integer` | Number of attempts to perform this operation. Default is 1 attempt | | sleepBetweenAttempts | `Integer` | Interval of time between the attempts. Default is 1000ms | | Activate | `any` | Activate the task | ## Outputs | Name | Data Type | Description | | ------ | --------- | --------- | | Success | `Boolean` | Triggered when the task is executed with success | | Error | `Error` | Triggered when the task failed for some reason | ## Settings On the `General` tab, you have the usual settings and the following settings: | Name | Data Type | Values | Default | Description | | ------ | --------- | --------- | --------- | --------- | | Directory path | `String` | | | Directory path | | Number of attempts | `Integer` | | 1 | Number of attempts to perform this operation. | | Sleep between attempts | `Integer` | | 1000 | Interval of time between the attempts. | For the `Directory path` you can use tokens as represented below: ```bash Available tokens: ${path} - Watched path ${archive} - Archive path ${temp} - Temporary directory of the user ${id} - DriverId ("\" chars replaced with "_") Examples: ${path}\subdir ${temp}\files\${id}\Error c:\source\Processed ``` ![Screenshot showing a settings page with an empty directory named "Dwrectory" and a server listed.](./images/image24.png) ## Behavior In this task you choose a driver when dropping it into the workflow (if you have more than one driver associated with the controller). Upon activation, will send a `EmptyDirectory` command to the driver where it will try to delete all files and subdirectories of `path` location. If it fails, will retry `attempts` times, waiting `sleepBetweenAttempts` milliseconds each time. If the operation is executed with success, a value `true` is emitted on the `Success` output. In case of the task , for some reason, is not able perform the `copy` operation, an `Error` is emitted. ## Remarks This task will return `success` even if the directory is already empty.