I work as a night-time photographer. Every night I collect about 800 RAW files + 800 JPG files. I skim my pictures selecting JPG files, that is to say I delete all the pictures I don't want, then I mark my JPG files with a grey tag and I transfer them into RAW files folder.

In the final phase I have my original 800 RAW files + more or less 200 JPG tagged files in the same folder. I now have 200 JPG files matching exactly 200 of the 800 RAW-file names.

I sort all my files in this folder by name and eventually I manually delete all the non duplicate files. The grey tags help me during this process: I leave each JPG file (with a grey tag) and its correspondent/matching RAW file (with the same name as the .JPG but with a .NEF extension) being right below the JPG.

The screenshot at the bottom of this post shows this final phase.

How can I automate this part of my work flow? Is there a simple script I could run?


  • I'm with you on the irritation factor of Nikon saving RAW+JPG as two files rather than one - but is it really that vital that you have both? What are you doing your initial 'contact sheet' culling in? I ended up just using ViewNX-i from NEFs only, save TIFs of my keepers, work up in Ps, then discard the intermediate TIFs [as the NEF+NKSC is smaller to keep long-term. Wish I could help on your automation idea, but I can't think of any simple way to tackle the problem. – Tetsujin Feb 15 '20 at 13:16
  • Which part of the flow do you want to automate? Just the removal of any RAWs where there is no JPG any more, the removal of both RAW and JPG if the JPG is either missing or not tagged "grey", or something else? – nohillside Feb 15 '20 at 13:34

You can automate the last step using Terminal.

You can see all .NEF files in a directory by using find. For example from within the directory.

find  *.NEF -type f

Then for each NEF check if corresponding JPG doesn't exist by using basename to remove the .NEF extension and then replace it with .JPG. This will print NEF files without a matching JPG.

find  *.NEF -type f -exec sh -c 'for f do [ ! -f $(basename $f .NEF).JPG ] && echo $f unmatched; done' find-sh {} \;

If that looks OK then replace echo $f unmatched with rm $f to delete the file rather than print the name.

find  *.NEF -type f -exec sh -c 'for f do [ ! -f $(basename $f .NEF).JPG ] && rm $f; done' find-sh {} \;

For example:

A1398% ls
1.NEF   2.JPG   2.NEF   3.NEF   4.JPG   4.NEF   5.NEF
A1398% find  *.NEF -type f -exec sh -c 'for f do [ ! -f $(basename $f .NEF).JPG ] && rm $f; done' find-sh {} \;
A1398% ls
2.JPG   2.NEF   4.JPG   4.NEF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.