Skip to main content
The d (delete) command removes files from existing archives without extracting or recreating the entire archive.

Syntax

Description

The delete command:
  • Removes specified files from archives
  • Updates archive structure and indices
  • Maintains archive integrity
  • Supports pattern matching for bulk deletions
  • Works with encrypted archives (requires password)
  • Does not extract files

Common Options

string
required
Name of the archive to modify. Must already exist.
string
required
Files or patterns to delete from archive. Supports wildcards.Example: *.tmp or logs/old.log
string
Provide password for encrypted archives.Example: -pMyPassword
flag
Recurse subdirectories when matching patterns.
string
Include files matching pattern.Example: -i!*.bak
string
Exclude files from deletion.Example: -x!important.txt
string
Specify archive type (usually auto-detected).
string
Set working directory for temporary files.
number
Set output log level.

Examples

Delete a single file

Output:

Delete multiple files

Delete all files with specific extension

Delete files in a directory

Delete with pattern matching

Delete from encrypted archive

Prompts for password:

Delete except specific files

Delete with confirmation

List files first, then delete.

Advanced Examples

Delete old log files

Delete all temporary files recursively

Delete specific directory

Delete files with verbose output

Delete from multiple archives

Safe delete (backup first)

Pattern Matching

Wildcards

  • * - Matches any characters
  • ? - Matches single character
  • [abc] - Matches any character in brackets

Examples

Deleting from Different Archive Types

ZIP archive

RAR archive (if writable)

Note: Some RAR archives may be read-only.

TAR archive

7z archive

Scripting Examples

Clean Temporary Files

Interactive Delete

Delete with Size Threshold

Delete Old Files by Date

Important Considerations

Archive Type Limitations

  • 7z - Full delete support
  • ZIP - Full delete support
  • TAR - Full delete support
  • RAR - Limited (depends on RAR version)
  • GZIP/BZIP2 - Not supported (single-file compression)

Solid Archives

For solid archives (-ms=on):
  • Deleting requires recompressing affected solid blocks
  • Can be slower than non-solid archives
  • May require significant temporary disk space

Encrypted Archives

  • Password required for header-encrypted archives
  • Password must match archive encryption
  • Cannot delete from corrupted encrypted archives

Performance Tips

  1. Delete multiple files in one command - Faster than multiple delete operations
  2. Use patterns instead of individual files - More efficient
  3. Avoid frequent small deletions - Reorganize and recreate if needed
  4. Set working directory - Use -w to control temp file location
  5. Solid archives - Consider recreating instead of deleting

Comparison: Delete vs Recreate

Delete Command

Pros:
  • Faster for small deletions
  • Preserves archive metadata
  • Atomic operation
Cons:
  • Solid archives may need recompression
  • Multiple deletions can fragment archive

Recreate Archive

Pros:
  • Can optimize compression
  • Clean archive structure
  • Can change compression settings
Cons:
  • Requires disk space
  • Slower for small changes
  • Temporary extraction needed
The delete command modifies the archive in place. Always keep backups of important archives before performing delete operations.
Deleted files cannot be recovered from the archive. Ensure you have backups or extract files before deletion if you might need them later.
Before deleting, use the list command to verify which files match your pattern:
Then delete:

Exit Codes