Photo Import questions

well…I’ll start off here with my code so far…

property EJ_Card : "EOS_DIGITAL"
property CFcard : "EOS_DIGITAL:DCIM:"
property hotfolder : "EOS"
tell application "Finder"
	set folderList to (every folder of folder CFcard whose name contains hotfolder)
	
	
	if folderList is {} then
		display dialog "Folder " & quote & hotfolder & quote & " not found" buttons {"Cancel"} default button 1
		return
	end if
	set picFolder to choose folder with prompt "Choose destination folder" default location path to desktop folder
	
	set impfolder to (every folder of folder CFcard)
	with timeout of 9999 seconds
		move impfolder to picFolder
	end timeout
	
	repeat with i from 1 to number of items in folderList
		set this_item to item i of folderList as string
		tell folder this_item to set {label index, name, f} to {2, my strip_name(first file) & "-" & my strip_name(last file), it as alias}
		
	end repeat
	
	set name of (every folder of folder picFolder whose name contains "EOS") to "eos"
	set compFolder to folder "eos" of picFolder
	set label index of (every file of compFolder) to 2
	
	
	set jpg_files to (every file of compFolder whose name extension is "JPG")
	repeat with j from 1 to the count of jpg_files
		set jpg to (item j of jpg_files as alias)
	end repeat
	
	
	set raw_files to (every file of compFolder whose name extension is "CR2")
	repeat with r from 1 to the count of raw_files
		set raw to (item r of raw_files as alias)
	end repeat
	
	try
		make new folder at picFolder with properties {name:"JPGs"}
	on error the error_message number the error_number
		display dialog "JPGs FOLDER ALREADY EXISTS" buttons {"DON'T REPLACE"} default button 1
	end try
	
	
	try
		make new folder at picFolder with properties {name:"RAW"}
	on error the error_message number the error_number
		display dialog "RAW FOLDER ALREADY EXISTS" buttons {"DON'T REPLACE"} default button 1
	end try
	
	set jpg_folder to folder "JPGs" of picFolder
	set raw_folder to folder "RAW" of picFolder
	
	
	move jpg_files to jpg_folder
	
	
	move raw_files to raw_folder
	
	
	delete compFolder
	
	
	
end tell

on strip_name(f)
	set {name:Nm, name extension:Ex} to info for (f as alias)
	if Ex is missing value then return Nm
	return text 1 thru ((count Nm) - (count Ex) - 1) of Nm
end strip_name

tell application "Finder"
	eject CFcard
end tell

The purpose of this script was to obviously download photos and seperate them into seperate folders based on their file type. This script works for that, but I am looking for suggestions on how to have the script look for say JPGs before it does all the actions for JPGs, so if there isn’t any on the card, it won’t make the folder. Same for the Raw photos. PS, this script should work with any Canon Camera, it is evolving daily and I’m coming up with more and more ideas for it. I’m also wanting to know…

When you tell the script to move files A from folder B to folder X, where folder X has some but not all of files A…how do you get Applescript to not replace the files already in X and still move the ones that aren’t? I have tried all kinds of ways and can’t get it to work. It either replaces all the files in X or just stops the script on an “already exists” error. Thank you for any and all help.

Here is a suggestion for your first issue:

set jpg_files to (every file of compFolder whose name extension is "JPG")
if jpg_files's length ≠ 0 then
	repeat with j from 1 to the count of jpg_files
		set jpg to (item j of jpg_files as alias)
	end repeat
	tell application "Finder"
		try
			make new folder at picFolder with properties {name:"JPGs"}
		on error the error_message number the error_number
			display dialog "JPGs FOLDER ALREADY EXISTS" buttons {"DON'T REPLACE"} default button 1
		end try
		set jpg_folder to folder "JPGs" of picFolder
		move jpg_files to jpg_folder
	end tell
end if

In this way, all of your JPG work is contained within a single if/then section, which will only be accessed if there actually any JPG files in compFolder. Also, instead of putting the entire script inside of a Finder tell, try just using the Finder when you really need it (making new folders, moving files, etc.)

Good luck,