Search and remove duplicate files

Here a small piece of code which will search for the duplicates in the path you supply. It will generate a new file which contains the commands for deleting those duplicates.
Make sure you double check the resulting file!
The script requires that you have fdupes installed.
Install it in Ubuntu/Debian by running the following command in your terminal:

sudo aptitude install fdupes
#!/bin/bash
 
OUTF='rm-dups.sh'
echo "#!/bin/bash" > $OUTF
fdupes -r -f $1 | sed -r 's#(.+)#rm '\"'\1'\"'#' >> $OUTF
chmod +x $OUTF
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Live
  • StumbleUpon
  • Technorati
  • LinkedIn
  • MySpace
  • Reddit
  • Twitter
  • email

Leave a comment