GNU/Linux Desktop Survival Guide
by Graham Williams |
|||||
Duplicate Photos |
20200411 As presented in Section 17.6, duplicate files (photos in our case) can readily be found. Duplicates are easy to create when we are copying photos around on our storage and attempting to manage large collections of photos with different file naming schemes.
The fdupes package provides the fdupes command to find and remove duplicates. With no options fdupes lists groups of duplicated files in the specified directory:
$ fdupes . ./20180323_122434_02.jpg ./20180323_122434_01.jpg ./20180323_122434_00.jpg ./20030102_092312_03.jpg ./20031012_092312_00.jpg ./20200531_151245_01.jpg ./20200531_151245_00.jpg |
Use the --recurse
or -r
option to recurse into
subdirectories.
A summary of duplicates is obtained using the --summarize
or -m
option:
$ fdupes --summarize . 13567 duplicate files (in 6407 sets), occupying 16996.0 megabytes |
Deleting duplicates will retain the first listed file and so sometimes
it is useful to use --reverse
:
$ fdupes --order='name' --reverse . ./20180323_122434_00.jpg ./20180323_122434_01.jpg ./20180323_122434_02.jpg ./20031012_092312_00.jpg ./20030102_092312_03.jpg ./20200531_151245_00.jpg ./20200531_151245_01.jpg |
The following command will then delete duplicates, keeping the first file in the list:
$ fdupes --delete --noprompt --order='name' --reverse . |