Need Help Comparing Two Directories for Duplicate Files

0
6
Asked By TechieTurtle42 On

I have two directories and I'm sure there are duplicate files, but I need to confirm. We're talking about hundreds of files here, and I know some files exist in one directory but not in the other. I'm looking for a quick way to compare the file names and sizes in both directories. Ideally, I want a method that will show me files that share the same name but differ in size, as well as files that are present in one directory but missing in the other.

5 Answers

Answered By FileFinderX On

You might want to try `rsync -avn /dir1 /dir2`. Just remember to include the `-n`, so it runs in dry-run mode. It’s also a good idea to look into the manual for instructions on using the trailing slash (it can be confusing!). For an added layer of checking, you can include `-c` to compare checksums.

Answered By FileNinja99 On

What about this command? `diff <(cd dir1; du -s * | sort -n) <(cd dir2; du -s * | sort -n)`—it should help you with what you're looking for.

Answered By ChecksumFreak On

I've had a lot of success using checksums for this sort of comparison. I’ve got a script lying around; if nobody else posts it, I'll share what I can later!

Answered By CompareGuru88 On

An alternative you could use is `diff -rq /dir1 /dir2`. It's pretty effective and can be faster than `rsync`, depending on what you need. Definitely give it a shot!

Answered By DataDude77 On

You could also try a version of `find -exec md5sum | sort | uniq -c`. There are tools like fdupes and jdupes that work really well too, especially jdupes for larger collections since it’s pretty fast.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.