# Delete

The **Delete** internal command can be used to:

* Recycle files and folders (delete them to the recycle bin)
* Delete files and folders permanently (bypassing the recycle bin)
* [Securely erase](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/file_operations/copying_moving_and_deleting_files/deleting_files/secure_delete.md) files so they can't ever be recovered
* Empty the recycle bin
* Remove items from a [file collection](../../../basic_concepts/virtual_file_system/file_collections)

**Command Arguments:**

| Argument         | Type | Possible values   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ---------------- | ---- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ALL              | /S   | _(no value)_      | <p>Delete all files and folders without prompting. This can be used to override the <strong>Ask for confirmation for each file before deleting</strong> and <strong>Ask for confirmation for each folder before deleting</strong> options on the <a href="../../../preferences/preferences_categories/file_operations/deleting_files"><strong>File Operations / Delete Files</strong></a> page in Preferences.</p><p><em>Example:</em> <code>Delete ALL</code></p>                                                                                                                                                                                                                                                                                                                                                                                                          |
| EMPTYRECYCLE     | /O   | _(no value)_      | <p>Empty the system recycle bin. You can combine with the <strong>FORCE</strong> argument to suppress the confirmation prompt, and the <strong>QUIET</strong> argument to suppress the progress dialog.</p><p><em>Example:</em> <code>Delete EMPTYRECYCLE FORCE QUIET</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|                  |      | _\<drive letter>_ | <p>Empty the recycle bin for a specific drive.</p><p><em>Example:</em> <code>Delete EMPTYRECYCLE=C:</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ERASEEMPTYSPACE  | /O   | _(no value)_      | <p>Erase empty space on the current drive. Empty space will be overwritten with random data to ensure deleted files cannot be recovered. This can take a long time, and generally only makes sense with HDDs, not SSDs. (To secure-erase a single file (that hasn't been deleted yet) instead, see the <strong>SECURE</strong> argument instead.)</p><p><em>Example:</em> <code>Delete ERASEEMPTYSPACE</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|                  |      | _\<drive letter>_ | <p>Erase empty space on the specified drive. Must be the first parameter.</p><p><em>Example:</em> <code>Delete ERASEEMPTYSPACE=D:</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|                  |      | _passes:\<n>_     | <p>Specifies the number of erase passes, from 1 to 32. If omitted, the previous number of passes will be remembered, and a single pass will be used if no previous number exists.</p><p><em>Example:</em> <code>Delete ERASEEMPTYSPACE=passes:1</code></p><p>If both a drive letter and pass count are given, the drive letter must be the first parameter.</p><p><em>Example:</em> <code>Delete ERASEEMPTYSPACE=D:,passes:2</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| FAILNOTEMPTY     | /S   | _(no value)_      | <p>Fail when attempting to delete a non-empty folder, or any file. Must be combined with the <strong>NORECYCLE</strong> argument.</p><p><em>Example:</em> <code>Delete FAILNOTEMPTY NORECYCLE</code></p><p>Use <strong>SKIPNOTEMPTY</strong> instead if you want the command to continue considering other items after encountering a file or non-empty folder.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| FILE             | /M   | _\<filename> ..._ | <p>Specifies the name of the file or files to delete. If you don't provide this argument the command will delete all selected items in the source Lister. This is the default argument for the <strong>Delete</strong> command - you don't need to specify the <strong>FILE</strong> keyword.</p><p>If you only specify the filename instead of the full path of the file or files, Opus will look in the current source folder. You can also specify a <a href="../../wildcard_reference/pattern_matching_syntax">wildcard pattern</a>. Remember that if the filename contains spaces you need to enclose it in quotes.</p><p><em>Example:</em> <code>Delete *.tmp</code></p>                                                                                                                                                                                              |
| FILTER           | /O   | _(no value)_      | <p>Delete with filtering enabled (without having to activate the <a href="../../../file_operations/filtered_operations">delete filter</a> in the Lister first). Opus will prompt you to define the filter.</p><p><em>Example:</em> <code>Delete FILTER</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|                  |      | _\<filter>_       | <p>Delete using the specified filter. This must have previously been created from the <a href="../../../preferences/preferences_categories/filtering_and_sorting/filters"><strong>Filters</strong></a> page in Preferences.</p><p>You can also directly specify a <a href="../../wildcard_reference/pattern_matching_syntax">simple wildcard pattern</a>. When specifying a simple wildcard pattern as the filter, it only affects which files are deleted; all selected folders and sub-folders are deleted unless they contain a file which doesn't match the filter and thus isn't deleted.</p><p><em>Example:</em> <code>Delete FILTER "temp files"</code></p>                                                                                                                                                                                                          |
|                  |      | **shift**         | <p>Delete with filtering enabled if the Shift key is held down. Opus will prompt you to define the filter.</p><p><em>Example:</em> <code>Delete FILTER=shift</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                  |      | **alt**           | <p>Delete with filtering enabled if the Alt key is held down.</p><p><em>Example:</em> <code>Delete FILTER=alt</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
|                  |      | **ctrl**          | <p>Delete with filtering enabled if the Ctrl key is held down.</p><p><em>Example:</em> <code>Delete FILTER=ctrl</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| FILTERDEF        | /K/R | _\<filter>_       | <p>Lets you define a filter in <a href="../../textual_filters">text format</a> to only delete matching files from selected folders. This is similar to the <strong>FILTER</strong> argument, however the filter does not need to be predefined.</p><p>This is a <strong>/R</strong> argument and so everything after the <strong>FILTERDEF</strong> keyword will be treated as the argument's value.</p><p><em>Example:</em> <code>Delete FILTERDEF name match *.zip and size match > 2 mb</code></p>                                                                                                                                                                                                                                                                                                                                                                       |
| FORCE            | /S   | _(no value)_      | <p>Force the deletion of any files that are marked as read-only (have the <strong>R</strong> attribute set). This overrides the <strong>Delete read-only files automatically (without asking)</strong> option on the <a href="../../../preferences/preferences_categories/file_operations/deleting_files"><strong>File Operations / Delete Files</strong></a> page in Preferences.</p><p><em>Example:</em> <code>Delete FORCE</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| NOFROMFOCUS      | /S   | _(no value)_      | <p>The default behaviour for the <strong>Delete</strong> command is to operate on either the source file display, or the Folder Tree, depending on which one has the input focus. This lets you use the same command to delete folders in the tree as well as items in the file display. Specify this argument to force the command to always operate on the source file display and ignore the folder tree.</p><p><em>Example:</em> <code>Delete NOFROMFOCUS</code></p>                                                                                                                                                                                                                                                                                                                                                                                                    |
| NORECYCLE        | /S   | _(no value)_      | <p>Prevent the use of the recycle bin - files will be permanently deleted. This overrides the <strong>Delete to Recycle Bin where possible</strong> option on the <a href="../../../preferences/preferences_categories/file_operations/deleting_files"><strong>File Operations / Delete Files</strong></a> page in Preferences.</p><p><em>Example:</em> <code>Delete NORECYCLE</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| QUIET            | /S   | _(no value)_      | <p>Prevent the display of any confirmation dialogs or error messages.</p><p><em>Example:</em> <code>Delete FORCE QUIET</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| RECYCLE          | /S   | _(no value)_      | <p>Delete files by moving them to the recycle bin (if possible - not all drives support the recycle bin). Deletes to the recycle bin are not permanent - the files can be recovered until the bin is emptied. This overrides the <strong>Delete to Recycle Bin where possible</strong> option on the <a href="../../../preferences/preferences_categories/file_operations/deleting_files"><strong>File Operations / Delete Files</strong></a> page in Preferences.</p><p><em>Example:</em> <code>Delete RECYCLE</code></p>                                                                                                                                                                                                                                                                                                                                                  |
| REMOVECOLLECTION | /O   | _(no value)_      | <p>Remove selected files and folders from the file collection. If used outside of a file collection this command will do nothing.</p><p><em>Example:</em> <code>Delete REMOVECOLLECTION</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
|                  |      | **auto**          | <p>When used on files and folders in a file collection, the items will be removed from the collection. When used outside of a file collection, the items will be deleted as normal.</p><p><em>Example:</em> <code>Delete REMOVECOLLECTION=auto</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| SECURE           | /O   | _(no value)_      | <p>Perform a secure delete using the number of passes specified on the <a href="../../../preferences/preferences_categories/file_operations/deleting_files"><strong>File Operations / Delete Files</strong></a> page in Preferences.</p><p><em>Example:</em> <code>Delete SECURE</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|                  |      | _\<passes>_       | <p>Perform a secure delete using the specified number of passes (from 1 to 32 depending on your level of paranoia :)</p><p><em>Example:</em> <code>Delete SECURE=5</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| SHIFT            | /S   | _(no value)_      | <p>Modifies the behaviour of the <strong>Delete</strong> command if the Shift key is held down.</p><ul><li>If the <strong>Delete to Recycle Bin</strong> option is selected on the <a href="../../../preferences/preferences_categories/file_operations/deleting_files"><strong>File Operations / Delete Files</strong></a> page in Preferences, holding the Shift key down will disable the use of the recycle bin.</li><li>If the <strong>Delete to Recycle Bin</strong> option is not selected, the command acts as if the <strong>ALL</strong> and <strong>FORCE</strong> arguments are specified. In either case, if the Shift key is not held down, the <strong>SHIFT</strong> argument has no effect on the normal operation of the command. This argument is used to emulate the behaviour of Explorer.</li></ul><p><em>Example:</em> <code>Delete SHIFT</code></p> |
| SKIPNOTEMPTY     | /S   | _(no value)_      | <p>Skip over non-empty folders, and all files, without deleting them, while still considering subsequent items for deletion. Must be combined with <strong>NORECYCLE</strong>.</p><p><em>Example:</em> <code>Delete NORECYCLE SKIPNOTEMPTY</code></p><p>Use <strong>FAILNOTEMPTY</strong> instead if you want the command to stop completely as soon as it encounters any file or non-empty folder.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
