This Python script searches through a specified source folder (including subdirectories) and copies unique images to a destination folder, maintaining the original folder structure. Duplicate images are skipped, and a log file is created listing the paths of duplicate images.
The script is compatible with Python 3.6 and above.
- Iterates through a designated source folder (including subdirectories)
- Copies unique images to a destination folder, keeping the original folder structure
- Skips over duplicate images (comparing image content, not file names)
- Creates a log file listing the paths of all duplicate images
- Displays a progress bar in the terminal
The script supports the following image formats:
- JPEG (both
.jpg
and.jpeg
extensions) - PNG (
.png
) - GIF (
.gif
) - WebP (
.webp
)
- Make sure you have Python 3.6 or later installed on your system.
- Install the required package:
tqdm
usingpip install tqdm
orpip3 install tqdm
(depending on your Python version) - Download the script as
unduplicate.py
. - Open the
unduplicate.py
script in your preferred text editor. - In the script, set
source_folder
variable to the path of the folder containing the original images. - Set the
destination_folder
variable to the path of the folder where unique images should be copied. - Save the changes and run the script:
python unduplicate.py
For example, if you have a folder named 'images' containing the original images and you want to copy the unique images to a folder named 'sorted-images':
source_folder = "images"
destination_folder = "sorted-images"