Skip to content

Python code to find duplicate images (photos) and videos in folders recursively and delete them.

Notifications You must be signed in to change notification settings

s-chh/Find-Duplicate-Photos-Video

Repository files navigation

Find-Duplicate-Photos-Videos

Python code to find and display all the exact duplicate photos (images) and videos in a folder and delete them (optional).
Begins search at the current folder. Repeats it for all sub-directories as well.

Run commands

Type Run command
Photos python duplicate_exact_photos.py
Videos python duplicate_exact_videos.py

Or Run "duplicate_media_exact.bat" on a Windows system to run both programs sequentially (photos followed by videos).

Run Arguments

Argument Usage Default
folder Folder to begin the search. Subfolders are included. Current path
keep_largest Keep the file with the largest or smallest size among the duplicates. 1 for largest and 0 for smallest. 1: Keep largest
compare_size Photos are resized to this value for comparison.
Higher value compares more pixels but requires more RAM and runs slower.
300 gives accurate and fast results.

Requirements

This program requires Python with numpy, tqdm and CV2 libraries to function.
Run the following command to install the dependent libraries in the Python environment if they are not present already:

pip install -r requirements.txt

Finding Duplicates Logic

Photos are compared using pixel-wise comparison using cosine distance after setting them to a fixed size.
Videos are compared using pixel-wise comparisons using cosine distance on the first frame (with a fixed size) and by matching their frame length.

About

Python code to find duplicate images (photos) and videos in folders recursively and delete them.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published