Hi, I want to delete .cr2 files that don't have a .jpg file in another directory. The idea is:
-Search files in jpg directory
-Select files in .cr2 directory that dont have matching names
-Delete them while keeping the .cr2s that have a corresponding .jpg so I have raw files for the good photos
Is this possible in a single command or do I have to write a script to do this?
3 Comments
ignotum@lemmy.world · 5 pts · 32d
Everything can be done as a single (but often quite long) command, something like this:
What it does is
I haven't tested it so might be some typos in there, also maybe replace
rmwithechoand run it first just to see what files it would have deleted, there's no undo when you usermAlso if there are 100k+ files this is likely going to be relatively slow, then i would create two files containing the names of all the files in each directory, sort them, then there is a command to find differences between them very efficiently but i don't remember which...
cadekat@pawb.social · 2 pts · 32d
I believe
commis your friend here. Something like get the contents of both directories, strip the suffix, sort, pass both lists tocomm, re-add the extension, and delete those files.orsam@lemmy.zip · 1 pts · 26d
Does one of the
diffoptions in this discussion help to generate the list of files? I'm limited to a phone for a few days, but I can test them later.