I need a command line tool to remove duplicate files.

There are several. But I could not find one which always keeps the older files and deletes the newer versions.

I tried finddup, duff, fdupes. Maybe I was blind, but AFAIK there was not way to tell the tools to keep the older file.

  • This may help askubuntu.com/q/3865/178596 – Wilf May 26 '15 at 20:40
  • I'd say it is possible to script what you want. Find the duplicate files, then compare their timestamps with stat . I might try doing something like that later, but I'm not on my machine right now, so I can only suggest a thing – Sergiy Kolodyazhnyy May 26 '15 at 21:51
  • 1
    @Wilf the AskUbuntu question you mention lists a lot of tools. I tried three (or even more) tools, before asking myself. All of them seem to have not option which file to keep if you use auto-delete. – guettli May 27 '15 at 5:28

Probably too late for the O.P. but maybe useful to others:

rmlint --rank-by m [paths]

... will search in [paths] for duplicate files and create a shell script (rmlint.sh) that you can use to delete the duplicates. The --rank-by m option tells it to keep the file with the oldest mtime in each set. There are also several other original selection criteria options

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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