I am working on de-cluttering a company shared drive, and looking to remove duplicates. Is there any duplicate finding program that allows you to specify which directory's duplicates are to be removed?

I would like to be able to do: fdupes -rdN some_Folder master_folder so that it preferentially keeps the duplicates in one folder over the other folder.

This involves thousands of files, so doing it by hand is not really an option. If rdfind's results file is the only way to do it, what's the best way to use that file?

1 Answer 1


You can list all duplicates with fdupes and extend your command to delete everything it finds, except files in master_folder:

fdupes -r some_Folder master_folder | grep -v ^master_folder/ | xargs rm -v


  • the output list of all duplicate files is sent to grep, which will output everything but lines beginning (^) with string master_folder/.
  • this filtered list is sent one by one (using the xargs command) as an argument to rm command, so each of this files gets deleted. -v argument shows, which files actually got deleted

Caution: Be careful with the rm command, try first on some non-critical data!

Edit: I added -v argument to rm command, because without it, the whole command is running absolutely silently, without output, which might be an unwanted behavior.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .