A Python script for safely deleting old temporary files from specified directories. The script includes safety checks to prevent accidental deletion of critical system folders and provides a dry-run mode to preview what would be deleted.
- Delete files older than a specified number of days
- Dry-run mode to preview files that would be deleted
- Safety checks to prevent deletion from critical system directories
- Detailed logging of deleted files, skipped files, and any errors
- Cross-platform compatibility
- Clone the repository:
git clone https://github.com/amirhosseindotzip/OriginalNameFileDeleter.git
cd OriginalNameFileDeleter
- Modify the configuration in
main.py
:
# Set the target folder and age threshold
target_folder = r"C:\Users\yourusername\AppData\Local\Temp" # Change this to your target folder
days_to_keep = 30 # Change this to your desired threshold
- Set the dry-run mode:
In
main.py
, find thedry_run
variable in thedelete_old_files
function:
# Set to True to preview files that would be deleted
# Set to False to actually delete files
dry_run = True
- Run the script:
python main.py
- Dry-run mode (enabled by default)
- Critical path protection for:
- Windows system directories
- Program Files directories
- User's home directory
- Error handling for file access and permissions
- Python 3.6 or higher
- No additional dependencies required
😉
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.