Tuesday, October 18, 2011

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

Question

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

In your command prompt, go to the folder and run this:

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" (without quotes) in the dir command.

No comments:

Post a Comment