So I have a problem. I have WAY too many hard drives and backups from decades of computing. I just hoard everything. The issue is now I don’t know what I have duplicates of and what I don’t. or when I want to format an old external drive for something else, I’m not sure if I actually have a backup of it.
I just want a way to basically compare folders and see what files are missing or what are duplicates. I’m fine with CLI but I may prefer a GUI for this so I’m not deleting files by accident as easily…
I have searched around for this question but all the solutions seem way too complex for me.
Say you have files in /home/bridgenjoyer/Data, /mnt/Backup, and /mnt/data
So
for d in /home/bridgeenjoyer/Data /mnt/backup /mnt/data do find $d -type f -print0 done | xargs -0 md5sum | sort- generates a list of all plain files by path name
- runs md5sum on them, which outputs a checksum as “checksum filename”
- sorts them by checksum
So, for identical files, you get identical repeated checksum antries.
You can filter out repeated entries (e.g. using awk, a shell script, or python) and extract their name and path.
There are also various tools which deduplicate identical files by hard linking them, if they are on the same file system. These will get the same inode number shown with ls -l. You can find these tools in the Arch wiki.
Then you need a strategy how to organize these identical files. You cold put all files into an archive folder, tidy them up, and only make and keep backups which you don’t modify.
There’s a couple programs I use.
Meld, for comparing folders exactly: http://meldmerge.org/
Czkawka for finding duplicate and similar files all scattered around: https://czkawka.net/
I was literally about to link czawka
+1 for meld. Also, I use fdupes a lot just to see where many duplicates reside
I’m sure someone else has a better method, but I’d just use whatever file manager you have to consolidate everything into one folder and let the file system flag any dupes.
Have ten movie folders on a bunch of different drives? Pick the biggest one, attempt to move the next biggest one into it, ignore all dupes, repeat.
Again, though, there’s probably a better way
This would be my solution as well but I know there must be better ways !
I’m only familiar with CLI tools but at least for smaller directories diff works well. Say you have a backup directory and you want to see how it differs from a source directory:
diff -rq /source/directory /backup/directoryAnother trick is to use find to look for a unique file to see where, if at all, it’s backed up:
find /backup/directory -name unique-file-name.jpgI could start with this !
I love CLI where I understand it I just am not as trusting when dealing witharge amounts of files. Of myself.
Easy question, hard answer.
If you want the easy answer: one new folder, look through everything you want to keep, and copy it to the new folder. Then delete the rest.
For a quick deuplication, fdupes will find exact duplicates. Read the man page, because there’s a cache option you probably want to use.
If there are inexact duplicates, like photos or videos, use tools like czkawka.
+1 for czkawka, it was the only thing that worked for my lazy brain. It also works for exact duplicates.
No matter the method though, the way OP describes it it’s still going to be a slog. At least it was for me when I was in a similar situation.
rsync has a
--dry-run / -nflag that would tell you which files would be synced. Combined with--archive /-ait runs recursively.That said, it’s assumes file paths are matching between source and destination, so if things are scattered, it might not work well.
If you’re really scattered, I’d consider using a simple python script to walk directories and create a json file with results (maybe the sha256 for key and filename, size, absolute path, and created/modified stamps as fields). Then when you hit a duplicate key, you can dump the results and prompt a delete.
Or something. I’m just spit balling here.
I’m in the long process of sorting out tons of duplicate files too, and I’m using krokiet, which is the new GUI version of czkawka. It’s not perfect, but it is the best tool I have found so far.




