Skip to content

folder_clean — remove OS junk

Recursively finds the metadata files operating systems scatter through folders, and removes them. Dry run by default — a bare run reports what it would delete and removes nothing; pass --delete to actually delete.

folder_clean <folder> [options]

Built-in junk set

OS Files
macOS .DS_Store, ._* (AppleDouble forks), .localized
Windows Thumbs.db, ehthumbs.db, desktop.ini
Linux .directory

Options

Option Description
--delete Actually delete matches (otherwise dry run)
--pattern <glob> Extra file to treat as junk (repeatable)
--patterns-only Use only --pattern globs, not the built-in set
-j, --jobs <N\|-1> Threads for scanning/deleting (-1 = all cores)
-o, --output <file> CSV report (default clean-report.csv)
-v, --verbose Print each file as it is processed

The report has relative_path,size_bytes,action, where action is WOULD_DELETE (dry run), DELETED, or ERROR.

Exit codes: 0 nothing found · 1 argument/IO error · 2 junk found (and deleted, with --delete).

Examples

folder_clean "J:\Photos"                       # preview only
folder_clean "J:\Photos" --delete --jobs -1    # remove, using all cores
folder_clean ./project --pattern "*~" --pattern "*.tmp" --delete
folder_clean ./build --patterns-only --pattern "*.o" --pattern "*.obj" --delete