Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

delete

Permanently deletes files and directories. For safer deletes consider trash instead.

Syntax

- delete

Options

This action has no options.

Examples

Delete old temp files

rules:
  - name: Clean Temp Files
    locations: ~/tmp
    filters:
      - date_modified:
          before:
            days_ago: 7
    actions:
      - delete

Delete by extension

rules:
  - name: Remove Log Files
    locations: ~/Projects
    subfolders: true
    filters:
      - extension: log
      - date_modified:
          before:
            days_ago: 30
    actions:
      - delete

Delete with size filter

rules:
  - name: Remove Large Temp Files
    locations: /tmp
    filters:
      - size:
          gt: 100MB
      - extension: [tmp, temp, cache]
    actions:
      - delete

Safety recommendations

Always use dry run first

autotidy run --dry-run

Combine with specific filters

Don’t use delete without filters:

# DANGEROUS - deletes everything!
rules:
  - name: Bad Rule
    locations: ~/Documents
    actions:
      - delete

# SAFE - specific filters
rules:
  - name: Good Rule
    locations: ~/Documents
    filters:
      - extension: tmp
      - date_modified:
          before:
            days_ago: 30
    actions:
      - delete

Consider using trash instead

For most cases, trash is safer:

# Recoverable
- trash

# Permanent
- delete

Notes

  • Permanent: Files cannot be recovered after deletion
  • No confirmation: Executes immediately when rules match