fdupes icon indicating copy to clipboard operation
fdupes copied to clipboard

Is there any way to say if you find duplicate in dir2 witch are originally from dir1, delete them?

Open stephane-archer opened this issue 3 years ago • 11 comments

stephane-archer avatar Jan 22 '21 16:01 stephane-archer

Yes.. this would be really helpful. I have a directory (dir1) with 100 images and another directory (dir2) with a selected subset of 70 images (for let's say a family album).

If I run fdupes --delete --noprompt dir1/ dir2/ there is no way for me to tell fdupes to delete only from dir1 and not from dir2. No matter how many times I tried, it always deleted from my selected subset dir2 and I end up with the original 100 and losing the names / details of the selected ones.

shrinathk avatar Nov 12 '21 17:11 shrinathk

+1. This would be really helpful. Preserve the one copy in the first specified directory if multiples are found.

mdolenga avatar Dec 08 '21 04:12 mdolenga

A workaround might be using the ncurses terminal-UI and doing something like sel dir1/ followed by ds and prune.

NicoWeio avatar Jan 02 '22 21:01 NicoWeio

there is a fdupes fork called jdupes which can do (nearly) what you are searching for jdupes -rNdO dir2/ dir1/ would set dir2 as first and would delete any duplicates found in the second directory, so in this case from dir1/. Only if there is a duplicate in the first folder itself, in this case dir2/, it would delete this specific duplicate in dir2/ as well. https://github.com/jbruchon/jdupes

This is one of the features which many people are seeking, really sad that there is no implementation of that in the original fdupes program

Friday13th87 avatar Nov 15 '22 12:11 Friday13th87

jdupes does not do this, so please don't tell people that it might.

jbruchon avatar Nov 15 '22 14:11 jbruchon

jdupes does not do this, so please don't tell people that it might.

Hard to argue with you, but never the less your program jdupe is exactly doing as i wrote, meaning that you did not understand what i was trying to say. The Topic was: "Is there any way to say if you find duplicate in dir2 witch are originally from dir1, delete them?" I wrote: jdupes -rNdO dir2/ dir1 is doing (nearly) that, its doing what in the title was asked + deleting duplicates within the directories itself.

Example: you have dir1/a dir1/a dir1/b dir1/c dir1/d dir2/c dir2/d dir2/e dir2/e dir2/f with a1=a2, e1=e2 and you run jdupes -rNdO dir2/ dir1 on that folders and files, and you will end up getting: dir1/a dir1/b dir1/c dir1/d dir2/e dir2/f

end of story. So the command i wrote is doing as ask, only that its deleting duplicates within dir1 and dir2 as well, so if the folder is not to big you could make a copy of it and use that for the intentional deleting of duplicate in dir1/ or you just set dir2/ to read-only before running the command.

Friday13th87 avatar Nov 16 '22 06:11 Friday13th87

No, it doesn't. You are trying to tell the person who wrote the software how the software works and you're wrong. Parameter order only controls sorting. It will gladly destroy things in dir1 all day long. The title of the issue is asking to delete things in one directory if they exist in another directory. That implies NOT DELETING things in the "original" directory. You're telling this person that jdupes does this. IT DOES NOT DO THIS. I wrote the software. I can read and understand legalese and I write my own legal contracts. I choose words carefully and precisely. If there is a communication problem in this conversation, it's entirely on your end.

...speaking of which: now you're saying through your "example" that jdupes renames files.

jbruchon avatar Nov 16 '22 15:11 jbruchon

No, it doesn't. You are trying to tell the person who wrote the software how the software works and you're wrong. Parameter order only controls sorting. It will gladly destroy things in dir1 all day long. The title of the issue is asking to delete things in one directory if they exist in another directory. That implies NOT DELETING things in the "original" directory. You're telling this person that jdupes does this. IT DOES NOT DO THIS. I wrote the software. I can read and understand legalese and I write my own legal contracts. I choose words carefully and precisely. If there is a communication problem in this conversation, it's entirely on your end.

...speaking of which: now you're saying through your "example" that jdupes renames files.

You are acting like a little child, sorry to say that and you are pretty rude, even in the opened issues in your own repository and instead of working constructive you are just trying to proof that you are right, but sadly you are not. You dont like to help, you just like to show who the "big guy" is and you try to proof your abilities by telling random people what you are capable of, like writing a contract and so on -.-

Of course you know much better then me how your program is working and what it is capable of, but that does not mean that you are better in reading or understanding a given problem. And this situation is pretty easy and there is no need to know the code of the program.

In my first statement i did not say that it is fully acting as desired, thats why i wrote "nearly" what was asked.

so the answer is pretty clear and easy: @stephane-archer If you dont care about deleted duplicates from dir1 you can use jdupes with jdupes -rNdO dir1/ dir2/ this will delete every duplicate, but if there are identical files in dir1/ and dir2/ the left over file will always be in dir1/ (i think this was your initial intention) if you dont like to delete any files in your dir1/ then you can run the same command as @shrinathk

chmod 555 -R dir1/ [--> jdupes cant delete files here, but calculate hashes etc.]
jdupes -rNdO dir1/ dir2/
chmod 755 -R dir1/ [or whatever privilegs you like to give the folder]

Problems solved, cheers and i am out.

Friday13th87 avatar Nov 16 '22 16:11 Friday13th87

let's not fight guys, @Friday13th87 solution works only if dir1 has no duplicate, so it solves the problem in a subset of the issue, @jbruchon is right to mention the edge cases of duplicate in dir1 and it couldn't have meat data lost if I was not aware of it. @jbruchon have you thought about adding a "reference directory" or "read-only directory" option to jdupes?

stephane-archer avatar Nov 21 '22 20:11 stephane-archer

I have, but this is an inappropriate place to discuss my software. I only comment here rarely when I can help or to keep users of my software from being a pain in Adrian's backside. I don't care if the script solves a subset of cases because it's irrelevant. False claims were made about my software and it's my responsibility to shut them down hard.

jbruchon avatar Nov 21 '22 21:11 jbruchon