Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I run fdupes it finds more than 30,000 duplicate files. I need to keep one file and delete all the other duplicates (because some of them are systemfiles). Please give me a command or script to do this without pressing "1 or 2 or all" for each and every group of duplicate files.

share|improve this question

You can do this if you want to run this silently (I've just used it to clear 150 GB of dupes running on rackspace block storage ..£kerching!!)

fdupes -rdN dir/

r - recursive
d - preserver first file, delete other dupes
N - run silently (no prompt)
share|improve this answer
    
Ain't there an option that would move to trash instead of deleting dupes? – Augustin Riedinger Mar 21 at 14:04
    
Did for f in $(fdupes -f .); do gvfs-trash $f; done – Augustin Riedinger Mar 21 at 14:12
    
@AugustinRiedinger: Even better would be fdupes -f . | xargs -rd '\n' -- gvfs-trash if you have file names with spaces and special characters or many files. – David Foerster Jun 3 at 7:40

fdupes has a rich CLI:

fdupes -r ./stuff > dupes.txt

Then, deleting the duplicates was as easy as checking dupes.txt and deleting the offending directories. fdupes also can prompt you to delete the duplicates as you go along.

fdupes -r /home/user > /home/user/duplicate.txt

Output of the command goes in duplicate.txt.

fdupes will compare the size and MD5 hash of the files to find duplicates.

Check the fdupes manpage for detailed usage info.

share|improve this answer
    
I found a way. yes 1 | fdupes -rd /mnt/hda5/midi_files – user84055 Aug 18 '12 at 9:52
    
See also superuser.com/a/691551/122096 – x29a Jul 30 '15 at 17:22

I have used fslint and DupeGuru for quite some time.

  • FSlint supports selection by wildcard and other cleanup methods
  • DupeGuru supports regex

Both can handle >10000 files/folders

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.