separate raw and jpg images

my camera shoots jpgs or raw+jpgs

i’m trying to make a workflow that throws away the jpg’s from the raws but leaves the images shoot in only jpg untouched.

The names of of the images shoot in raw+jpeg are identical (eg L10045.RAW and L10045.jpg) except from the extention

anyone an idea how to do this?


Hi Mal,

This will move all the files in the chosen folder, that have
an extension of “raw”, to the trash.

--Choose the folder containing the pictures
set theFolder to choose folder

tell application "Finder"
	set thePics to every file of theFolder
	--Loop through each picture and see
	--if the name extension is "raw"
	--if it is then move it to the trash
	repeat with i from 1 to count the thePics
		set thisPic to item i of thePics as alias
		set thisExt to name extension of thisPic
		if thisExt = "raw" then
			move thisPic to the trash
		end if
	end repeat
end tell



hi graig
Thanks for your reponse
maby my first post is not too clear.

My camera takes photos in jpg or raw format.
when i take a photo in raw it automatically generates a jpeg image of that shot

What i want to achieve is a workflow that sends photos taken only in jpg direct to iphoto and the raw images to aperture and trows away the accompanying jpg images. I don’t want the jpg’s that came with the raws to be imported in iphoto nor imported in aperture.

in steps i imagine the workflow when i import a jpg (A.jpg) and a raw (B.raw and B.jpg) like this

1 copy the images from the card to the computer
2 make a script that sees B.raw and throws away B.jpg
3 import A.jpg in iphoto
4 import B.raw in aperture

1-3-4 I managed to do in automator

For 2 I think I have to make some if /then rule
if B.raw exist then throw away B.jpg
but i haven’t a clue how to do this

Try something like this for your step 2:

set targetFolder to choose folder default location alias ((path to desktop folder as Unicode text) & "JPG-RAW Test:")

|remove JPG for RAW|(targetFolder)

to |remove JPG for RAW|(fldr)
	tell application "Finder"
			if class of fldr is not folder then set fldr to folder fldr
		end try
		ignoring case
			set rawNames to name of files of fldr whose name ends with ".raw"
		end ignoring
	end tell
	set jpgsWithRaw to {}
	repeat with n in rawNames
		-- we know they end in .raw, just trim off the last 4 characters and add ".jpg"
		set jpgName to text 1 through -5 of contents of n & ".jpg"
		ignoring case
			tell application "Finder" to ¬
				set jpgsWithRaw to jpgsWithRaw & (files of fldr whose name is jpgName)
		end ignoring
	end repeat
	tell application "Finder" to delete jpgsWithRaw
end |remove JPG for RAW|

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 3.0.4 (523.12)
Operating System: Mac OS X (10.4)

Hi Chris
This is exactly what i was looking for !
Thanks ! :slight_smile:

I’m using an automatorworkflow, it seperates RAW and jeps shot with my leica camera, and then converts the RAW in DNG.

to seperate the RAW and JPG images i’m using this script

I would like to use this workflow also for images shot with my nikon camera.
from this camera i get .NEF or .JPG images.

When I run the workflow with only .NEF or .JPG images the script blocks ( and so the workflow) when it doesn’t find any images with the extention .RAW

is there a way to change this script so it doesn’t block when there are only .NEF and/or .JPG images in the folder?

there no need for the script to seperate NEF and JPG from the nikon.