Easily delete jpg files when shooting RAW+jpg

As a photographer, I always shoot in RAW files. But unfortunately, my Canon G11 cannot be set for only RAW files. If I want a RAW file, it will be a RAW+jpg. So, I always have to get ride of the jpgs once unloaded on my computer. In the easiest scenario, I could just delete all the jpgs files once exported.

But the G11 is the family camera. My wife sometimes shoot in the green square mode. When set to the green square, there is no RAW file, only jpg. So if I unload the pictures, I cannot just delete the jpgs as I will delete those pictures which exists only as jpgs.

I could check every file and delete it by hand, but we use computers, they should do the job. Actually, the job can be done by a 10 lines shell script.

On any UNIX based platform (which mean OsX or Linux), it is easy to write a little script to launch in the unload folder. Here it is. For every jpg file, it checks if a file with the same name exists with the .CR2 suffix. If so, the jpg is deleted, otherwise, no.

#!/bin/sh

for i in *.JPG
do
    if [ -f $(basename $i .JPG).CR2 ]
    then
        rm $i
        echo "deleted $i"
    else
        echo "kept $i"
    fi
done

This is just a basic script. You may have to change the suffixes for your camera. If you are a Nikon user, you’ll have to compare to .NEF instead of .CR2.

You can of course add in the condition any action you want such as another message or to move the resulting file.

I wrote this kind of script to be executed once I unload my images from the memory card. As I also like to rename the images according to the timestamp, my script look rather like this one:

#!/bin/sh

for i in *.JPG
do
    if [ -f $(basename $i .JPG).CR2 ]
    then
        rm $i
        echo "deleted $i"
    else
        echo "kept $i"
    fi
done

exiv2 -r'%y%m%d-%H%M%S' -F rename *

So, once all JPGs are thrown away and all the remaining files are renamed, I can import them in my photo management software.

About Darko Stankovski

Darko Stankovski is the founder and editor of Dad 3.0. You can find more about him trough the following links.

Darko Stankovski

Darko Stankovski is the founder and editor of Dad 3.0. You can find more about him trough the following links.

You may also like...

Leave a Reply