This Python program helps you find duplicate files in a specified directory and delete them after previewing. It supports various file types, including images and text files, and provides a graphical interface for easy file selection and deletion.
- Find Duplicate Files: Scans the selected directory for duplicate files based on their hash values (SHA-256).
- Progress Bar: Displays a progress bar during the scanning process.
- File Previews: Shows image previews for image files and text previews for text files, helping you review duplicates before deletion.
- Selectable Duplicates: Allows users to select which duplicate files to delete, with a "Select All" option for each group of duplicates.
- Cross-Platform Notifications: Sends a desktop notification when the scan is complete.
- Deletion Confirmation: Asks for confirmation before deleting selected duplicate files.
- Windows Beep: Plays a beep sound on Windows when the scan is finished.
- Python 3.x
tkinter
for the graphical user interfacePillow
(PIL) for image previewsplyer
for cross-platform notificationswinsound
for Windows beep soundconcurrent.futures
for parallelizing the file hashing process
To install the required packages, you can run the following commands:
pip install pillow plyer
- Run the script, and it will prompt you to select a folder to scan for duplicates.
- The program will scan the directory and calculate the hash values of each file.
- After the scan is complete, a window will appear showing the duplicate files grouped by hash value.
- You can select individual files to delete or use the "Select All" button to select all duplicates in a group.
- When you're ready, click the "Delete Selected" button, and the program will confirm the deletion before proceeding.
- Hash Calculation: For each file in the selected directory, the program computes a SHA-256 hash to uniquely identify the file content.
- Duplicate Detection: Files with the same hash value are considered duplicates.
- File Deletion: Once duplicates are identified, you can choose which files to delete, and the program will delete the selected files.
- Preview and Selection: Image files will be displayed as previews, and text files will show a portion of their contents for easier identification.
calculate_hash(file_path, block_size)
: Computes the SHA-256 hash of a file.find_duplicates(directory, progress, progress_label)
: Scans the directory and identifies duplicate files, updating the progress bar.delete_selected_duplicates(duplicate_dict, selected_files)
: Deletes the selected duplicate files.duplicate_selection_gui(duplicate_dict)
: Displays the duplicate files in a GUI with options to select and delete them.main()
: The main function that initializes the program and starts the duplicate file finding process.