adrianlopezroche / fdupes

FDUPES is a program for identifying or deleting duplicate files residing within specified directories.
2.42k stars 186 forks source link

sort by order of directory arguments #91

Open cjfp opened 6 years ago

cjfp commented 6 years ago

Hello, thanks for fdupes. I'm using version 1.6.1. Given directories 1 and 2 with no intradir duplicates, I would like:

$ fdupes -rdN 1 2

to remove duplicates between 1 and 2 only from 2, and

$ fdupes -rdN 2 1

to remove duplicates between 1 and 2 only from 1. Something like:

$ mkdir 1 2
$ echo x > 1/a
$ echo x > 2/a
$ echo y > 2/b
$ echo y > 1/b
$ fdupes -o dir -rq1 1 2
1/a 2/a
1/b 2/b
$ fdupes -o dir -rq1 2 1
2/a 1/a
2/b 1/b

It looks like -o name considers the directory name, but -i does not:

$ fdupes -rq1 1 2
2/b 1/b
1/a 2/a
$ fdupes -o name -rq1 1 2
1/b 2/b
1/a 2/a
$ fdupes -o name -i -rq1 1 2
1/b 2/b
1/a 2/a
$ fdupes -rq1 2 1
1/a 2/a
2/b 1/b
$ fdupes -o name -rq1 2 1
1/b 2/b
1/a 2/a
$ fdupes -o name -i -rq1 2 1
1/b 2/b
1/a 2/a

I'm not sure but I think -i might not be working as intended. I am able to get what I want if I do:

$ mkdir m n
$ mv 2 m
$ mv 1 n
$ fdupes -o name -rq1 m n
m/2/b n/1/b
m/2/a n/1/a
melolontha-melolontha commented 1 year ago

Since the order in case of a tie is not documented, I tried to see if the paths to be searched determine the order of the output. In my example, they did not. Finds in the Screenshots directory came before finds in tmp, regardless of which path was searched first.

I would have proposed to add more than one option in the -o argument, e.g. -o name,path,ctime such that the second comma separated argument is applied in cases of a tie in the first argument and so on.

Unfortunately -o path is not available currently and the ability to combine sorting criteria is missing too.

For more flexibility I would propose to add iname, ipath, ictime as inverse sorting criteria by their proper tokens.

Even more general would be an extension of being able to name the folders to be searched in a file, with the order there being the deciding factor in the event of a tie in a path or ipath criterion. This could even be an alternative to specifying the directories in the call itself. The danger is large to undo directory renaming completely after one has made it only briefly for an operation with fdupes. Besides, with fdupes you don't always find what you are looking for right away. Then this would save a lot of typing.