
UploadSleuth reconciles files in the uploads directory against WordPress attachment metadata and database references.
Files without a detected reference are shown as likely stray candidates. They are not declared safe to delete. The plugin encourages a review, dry-run, and quarantine workflow before permanent removal.
wp_delete_file().A file can be referenced by an external system, theme or plugin code, encoded data, a custom database, or another location the plugin cannot inspect. Make a verified backup and test quarantined files before deleting anything permanently.
UploadSleuth is maintained by the same developer behind Notificator – Alerts & Notifications, a WordPress plugin for turning site events into dashboard alerts and optional mobile or MQTT notifications. Browse the UploadSleuth source code on GitHub.
wp upload-sleuth
wp upload-sleuth --uploads-subdir=2025 --format=json
wp upload-sleuth --older-than=90 --min-size=100 --summary-only
wp upload-sleuth --quarantine --dry-run
wp upload-sleuth --delete --dry-run
wp upload-sleuth --backup-delete --dry-run
Real permanent deletion requires wp upload-sleuth --delete --yes. A real backup-and-remove operation similarly requires wp upload-sleuth --backup-delete --yes.
Long scans can be checkpointed and resumed:
wp upload-sleuth --state-file=/path/upload-sleuth-scan.json
wp upload-sleuth --resume --state-file=/path/upload-sleuth-scan.json
wp upload-sleuth --clear-state --state-file=/path/upload-sleuth-scan.json
Use --save-report=/path/upload-sleuth-report.json to export JSON findings, then import that file from the WP-CLI tab in the dashboard. Interactive table scans display an animated progress bar.
UploadSleuth fires upload_sleuth_* lifecycle and file-action hooks for notification and automation integrations, including scan started/completed/stopped, action started/completed, and upload_sleuth_quarantine_emptied. The source argument identifies dashboard or cli. See the project README for the complete hook list.