Summary:
- Folder A has only many Excelent files
- Folder B has many folders of mixed Excelent/Good/Bad files
How can I delete files in Folder B folders only in case they will be in Folder A.
In other words, how to check if Folder A files exist in Folder B folders then delete from Folder B folders?
Idea of solution Maybe a command which:
- Checks part of alphabet like all starting with A
- Executing deletion on files found in Folder B subfolders
- Repeat 1. + one alphabet up.
Reasons why other duplication programs were bad:
- Long time until 1st deletion - it's only when finished scanning
- And no possibility to choose deleting in Folder B. It's possible only to keep latest and something else also, but not by choosing in which folder to keep.
Useless history: Files were copied from Recuva in Folder B and partly arranged, but a lot of them are bad. So first, I'm thinking Folder B comparing if exist to those which recovered again, but now just Excelent recovered in Folder A by Recuva so most of Excelent will be just in Folder A.
Example file tree:
.
├── A
│ ├── 1.png
│ ├── 2.png
│ └── Excellent
│ ├── e1.png
│ └── e2.png
└── B
├── 1.png
├── 2.png
├── Bad
│ ├── 1.png
│ ├── 2.png
│ ├── e1.png
│ └── e2.png
└── Excellent
├── e1.png
└── e2.png
And other programm isnt in 10.04 ill try when ill get to some 12.04 but is there alternative to 10.04 also?
– Kangarooo Jan 13 '13 at 02:31B${1#*A}
toB${1#*Good}
. This is a bash expression which removesGood
from the filename and replaces it withB
. The tools used in this solution fairly common to all versions of unix, and should work fine in Ubuntu 10.04. – unutbu Jan 13 '13 at 02:45rdfind
. – unutbu Jan 13 '13 at 11:35find
/xarg
command does that. Do you mean something else by "recursive"? – unutbu Jan 14 '13 at 01:10Ah i did more tests and wasnt sure why not working. Then i forgot how i had files for test distributed. So now i found that if duplicate file is in different subfolder then primary file subfolder then it isnt deleted.
So result deleted all in exact same folder content Excellent but not same files in folder Bad.
– Kangarooo Jan 15 '13 at 05:21fdupes
: by default, it keeps the oldest file, so if that happens to be on drive B, your are modifying drive A. Worse, it will remove any duplicates that exist on drive A only, which might be excellent files that are duplicated for a reason! – Bas Swinckels Aug 12 '20 at 08:41