Points in Focus Photography

Script to find and Delete JPEGs form RAW+JPEG Pairs

Documentation

The other day, a friend of mine trying to free up some space on their computer asked me if I knew how to delete the JPEGs from a RAW+JPEG pair in Lightroom. After scratching my head on that for a while, I threw together a Powershell script to do the job, and so I’m sharing it here in the event it might be helpful for someone else.

WARNING: Advanced computer stuff ahead.

This script is for Windows and requires Microsoft’s Powershell environment to execute. I’ve tested it in Powershell version 3 on Windows 7. If you don’t have Powershell installed, the latest version can be downloaded from Microsoft.

To run the script, place it in the top-level directory of the directory tree where you want it to scan; right-click on it and choose “Run in Powershell.” The script will prompt you before running whether you want to just build a list of files to remove or delete them. I recommend not deleting files on the first pass, just to be safe as the deletions done by this script aren’t reversible.

The script considers a JPEG to be part of a RAW+JPEG pair when the files have the same name but a different extension (.nef, .cr2, or .dng for raw, and .jpg for JPEGs), and exist in the same directory. The script recursively scans through every child directory starting from the directory the script is executed from looking for RAW+JPEG pairs.

Results are always logged to raw&jpeg.log in the same directory as the script itself.

Due to the nature of the process, the script can take some time to run, and doesn’t display progress unless it finds matches.

I recommend running the script and verifying that the files it’s selected to delete are in fact RAW+JPEG pairs, before deleting them.

This tool is provided without warranty or support.

Download: Clean RAW+JPEG JPEG.zip

 

Comments

md

This line has a bug: $pairsFound = true;

It should read $true instead. Script works well, thanks for posting it.

    Jason Franke  | admin

    @md, Thanks for catching that. It’s been fixed.

Leave a Reply

Basic Rules:
  • All comments are moderated.
  • Abusive, inflamatory, and/or "troll" posts will not be published.
  • Links to online retailrs (eg., Amazon, Ali Express, EBay, etc.) either directly, or indirectly through 3rd party URL shorternrs, will be removed form your post.
  • Extremely long comments (>1000 words) may be blocked by the spam filters automatically.
  • If your comment doesn't show up, it may have been eaten by the spam filters; sorry about that.
  • See the Terms of Use/Privacy Policy for more details.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Follow me on twitter for updates on when new comments and articles are posted.

Email Notice Details: By checking the above checkbox, you are agreeing to recieve one email at the email address provided with this comment, for the sole purpose of notifing you that the article author has been reseponded to your comment.

Our cookie and privacy policy. Dismiss