0

Can I preserve second files in list, when works with fdupes?

fpupes -N -r .

Preserve first files in list, but I need save the SECOND files. I have about 2000 duplicates and type for each 2 in prompt

fdupes -d -r .

Is to hard..

3 Answers 3

1

You cannot do this with fdupes. But you can use fdupes to find the dupes and remove the first one yourself like this:

fdupes -rn .|awk 'BEGIN{first=1} (first){print;first=0} /^$/{first=1}'

This will print out all the first files found by fdupes, which you then can delete with:

command | while read file
do
    rm "$file"
done

Not tested, watch out!

1

You can reverse the order in which the files are displayed with the -i option.

From the man page:

       -o --order=WORD
              order files according to WORD: time - sort by mtime, name - sort by filename

       -i --reverse
              reverse order while sorting

So for you

fdupes -N -i -r .

should work.

1
  • This works. I had tried sorting with -o name before. It sorted on output but did not delete according to the sorted output.
    – bomben
    Sep 25, 2020 at 11:47
0

Use rmlint; it has heaps of options for deciding which file to delete.

You must log in to answer this question.

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