Suggestions for a somewhat complicated photo import

hello all…let me preface by saying I am a total newbie to this scripting thing, but I understand how powerful it can be. I’m a professional photographer and have a normal convention for importing photos that I would like to automate if possible. Basically what I want to do is put in a CF card, then start my automation which would open the disk (Nikon D200) open the “DCIM” folder and rename that next folder (102ND200) to the name of the first file in it and the last file in it, for example: “CWM_7011-CWM_7134” then have it label that folder red and then copy it into the pictures folder. I can get it to do everything except rename the folder. Any and all suggestions are welcome. Thanks so much, if we can get this to work it will INCREDIBLY increase my workflow on set.

Hi,

try this (just an AppleScript, no Automator action):

property CFcard : "Nikon D200:DCIM:"
property hotfolder : "102ND200"
set picFolder to path to pictures folder

tell application "Finder"
	if not (exists folder (CFcard & hotfolder)) then
		display dialog "Folder " & quote & hotfolder & quote & " not found" buttons {"Cancel"} default button 1
		return
	end if
	tell folder (CFcard & hotfolder) to set {label index, name, f} to {2, my strip_name(first file) & "-" & my strip_name(last file), it as alias}
	move f to picFolder
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

you can even automate the whole thing when the CF card is inserted
using launchd. Take a look at Craig Smith’s launchd article

Hi Stefen,

I think the folder “102ND200” is one in a series that will be created by the camera each time the folder reaches a set limit of contents.

So the next folder would be “103NDxxx” I think the number normally goes up to “999NDxxx” then I think either resets or
the last digits are changed. But the 100 to 999 does not.

But basically there needs to be a way to check for the new folder.

At a guess each folder in the DCIM folder will be 8 digits long, but there maybe more than one.
The renamed folders names would be longer . “CWM_7011-CWM_7134”

So a script that looks in a repeat loop, for folders with 8 characters long and contains jpegs may work.

I can not test this at the mo, Sorry

Thanks Mark, could be.
Unfortunately I don’t own a Nikon camera, so I can’t either test it.
But it sounds not to be a big problem :wink:

oh man, that totally freakin works! I already thought of the “102ND200” changing to 103 ad so on, but that only happens every 3000 photos, so I could just change the script, not really that big of a deal. I don’t know if there’s a way to just look for the D200 part of the folder name, because that will never change. There may also be a setting somewhere in my camera for naming that, which is how I got the prefix CWM for the filenames. StefanK, I’m gonna use part of your script you posted and try to play with automator, because I would like it to prompt me for where specifically to copy the files to. I realized after I ran your script, that I want the photos to go into the specific folder inside pictures for whatever shoot I’m on. Like if I’m on a shoot for Honeywell I’ll have a folder named like “honeywell orlando” in the picture folder, and then the folders that I’m copying will go inside that. If I could get it prompt me on where to save the folder to, in the middle of the action, that would be totally sweet. Isn’t it possibly to do this with Automator?

Thanks so much everyone, this is REALLY going to speed up my workflow. PS if there is anyone reading this that takes a lot of photos, and end up having to split things off on seperate drives and such, this folder naming convention is a fantastic way to keep up with your specific files. And by renaming the folder on the card it makes the photos unreadable in camera, so when you put the card back in the camera to format it and shoot more, you have a second confirmation that it’s already been downloaded and backed up. Thanks again!

Hi,

of course it’s possible also with Automator, you can put it into a Run AppleScript action,
but you can also save the script as an application and run it directly.
To choose a folder manually replace the line set picFolder to.. with

set picFolder to choose folder with prompt "Choose destination folder" default location path to pictures folder

Using Stefens Script

This will look for any folder in the DCIM folder whose name contains “ND20” and process it.
(I tested this on a made up folder structure , not an actual CF card)

property CFcard : "Nikon D200:DCIM:"
property hotfolder : "ND20"
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 pictures folder
	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}
		move f to picFolder
		
	end repeat
	
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

thanks to everybody for your replies and help, I finished the script, it works fantastically. I saved it as an application and use Image Capture to automate it when I put a card in the reader. Here’s the final script, thanks so much to all who contributed.


property CFcard : "Nikon D200:DCIM:"
property hotfolder : "ND20"
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 pictures folder
	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}
		set impfolder to (every folder of folder CFcard)
		with timeout of 555 seconds
			move impfolder to picFolder
		end timeout
		
	end repeat
	
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

I had to make a little bit of a change with the import because I think with it being a drive, instead of folders like you guys were testing on, when it went to import the photos it was trying to find the “ND20” folder, which since we renamed it, it didn’t exist. It took me awhile to realize that I just needed every folder in the “DCIM” folder…before I was trying to get every folder with “CWM” in the title, but it didn’t always work…anyway, this does it exactly. Thanks again!