Thursday 12 January 2017

jpeg - How to delete JPG files, but only if the matching RAW file exists?


My early (Canon G2) photos are all JPG, but when I got my Nikon D90 I initially shot in JPG, then switched to RAW+JPG, and now I would like to switch to RAW only.



I have literally thousands of photos on my HDD. The photos are in sub-directories (by date) under a single directory called Import.


I am about to import all these photos into Lightroom 3.0, however, I would like to delete all the JPG files, but only where there is already a corresponding RAW file (ie. I no longer want to keep JPG and RAW versions of the same file).


If I can do this easily within Lightroom (after importing everything, including the duplicate JPG files) that would be great. It would also be OK if there were an easy way to do this before importing the files (but hopefully this wouldn't involve having to visit every directory looking for filenames with both JPG and NEF extensions).


Does anybody know of a way to do this (in Lightroom, or with some tool/script in Windows)?



Answer



On Windows, go to the folder, and run this in a command prompt:


for /f "delims==" %r in ('dir /b *.nef') do del "%~dpr%~nr.jpg" 2> nul

Basically, it goes through the current folder, runs through the NEF files, and deletes the JPG if present. It ignores any errors if the JPG is not there.


If you want subfolders, include /s in the dir command.



No comments:

Post a Comment

Why is the front element of a telephoto lens larger than a wide angle lens?

A wide angle lens has a wide angle of view, therefore it would make sense that the front of the lens would also be wide. A telephoto lens ha...