Skip to content

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.

Notifications You must be signed in to change notification settings

AmirhosseinDotZip/OriginalNameFileDeleter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

OriginalNameFileDeleter

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.

Features

  • 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

Usage

  1. Clone the repository:
git clone https://github.com/amirhosseindotzip/OriginalNameFileDeleter.git
cd OriginalNameFileDeleter
  1. 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
  1. Set the dry-run mode: In main.py, find the dry_run variable in the delete_old_files function:
# Set to True to preview files that would be deleted
# Set to False to actually delete files
dry_run = True
  1. Run the script:
python main.py

Safety Features

  • 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

Requirements

  • Python 3.6 or higher
  • No additional dependencies required

License

😉

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages