Delete unwanted JPG files

How to select an huge amount of photos in CR2 (canon RAW format) and JPEG?

After any photo shooting session I have always the same problem: select the right photos and delete the bad ones among hundreds clicks.
Normally I review the RAW files, then I select which photos need some post-processing actions and delete the wrong photos. After this first step, I need to delete the JPEG files corresponding to deleted CR2 raw photos.
I wrote this simple python script that searches for missing CR2 files and add a suffix “_DELETEME” to the corresponding JPG photo, in order to easily identifying the photos to delete.

Disclaimer: this is my FIRST working python script

Prerequisite: shoot in CR and JPG format using the same file name

#!/usr/bin/python
import glob
import os.path
for image in glob.glob("*.JPG"):
   fileName = os.path.splitext(image)[0]
   print "Checking " + fileName
   if (os.path.exists(fileName+".CR2") == False):
      print "Mark as DELETEME " + image
      os.rename(image, image+"_DELETEME")

print "Done! Review the DELETEME files and if it's all OK...delete them!"

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.