This script deletes files and folders that don’t match the extensions you specify. Good for sorting folders after using recovery tools like Testdisk, sorting backups, or dumps.
- Python 3.6+
- tqdm (
pip install tqdm)
Download and install Python from https://www.python.org/downloads/
Make sure to check "Add Python to PATH" during installation.
Install tqdm by Open Command Prompt and run:
pip install tqdmIt's recommended to first do a dry run: (default)
python clean.py -p "C:\Path\To\Folder" --keep .jpg .png .mp4To actually delete files and folders add run argument:
python clean.py -p "C:\Path\To\Folder" --run --keep .jpg .png .mp4- Once finished it will generate a cleanup.log file in the same directory as the script
- Running multiple times will append to the log file.
- You can use any extension with --keep, not just media. For example, to keep only .doc files:
python clean.py -p "D:\Docs" --run --keep .doc-
Extensions must include the dot (e.g., .jpg, not jpg).
-
Files with no extension are treated as deletable.
-
If you see an error like:
ModuleNotFoundError: No module named 'tqdm'Just run pip install tqdm and re-run the command
-
Specifying your path with -p is required
-
Specifying the extension names you would like to keep with --keep is required