Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stephane-archer opened this issue Jan 22, 2021 · 11 comments

Comments

@stephane-archer
Copy link

No description provided.

@shrinathk
Copy link

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.

@mdolenga
Copy link

mdolenga commented Dec 8, 2021

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

@NicoWeio
Copy link

NicoWeio commented Jan 2, 2022

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

@Friday13th87
Copy link

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

@jbruchon
Copy link

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

@Friday13th87
Copy link

Friday13th87 commented Nov 16, 2022

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.

@jbruchon
Copy link

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.

@Friday13th87
Copy link

Friday13th87 commented Nov 16, 2022

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.

@stephane-archer
Copy link
Author

stephane-archer commented Nov 21, 2022

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?

@jbruchon
Copy link

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.

@andunix
Copy link

andunix commented Apr 1, 2023

I somtime have a directory with duplicate files, but I'm not sure, if they are all duplicates. I used to clean them with the --delete-auto=path option of findrepe. Unfortunately, findrepe is no longer maintained, so I found fdupes as alternative. I would love to see a similar option in fdupe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants