Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
Hey guys, Tiger just came in the mail yesterday, and I'm having a ball! :D I'm trying to get an automator application ready for my mom which will download the pictures from her digital camera, move them to a specific dated folder, and scale them to 300 pixels. Here's what I've got so far:
Code:
on run {input, parameters}
	tell application "Finder"
		set mydate to day of (current date) as string
		set mymonth to month of (current date) as string
		if exists folder "Macintosh HD:Users:Craig:Pictures:eBay Temp:" then
		else
			make new folder at "Macintosh HD:Users:Craig:Pictures:" with properties {name:"eBay Temp"}
		end if
		if exists folder "Macintosh HD:Users:Craig:Pictures:Pictures:" then
		else
			make new folder at "Macintosh HD:Users:Craig:Pictures:" with properties {name:"Pictures"}
		end if
		
		
		set unknownfolder to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & ":"
		try
			alias unknownfolder
		on error
			try
				make new folder at "Macintosh HD:Users:Craig:Pictures:Pictures:" with properties {name:"untitled1"}
				set name of folder "Macintosh HD:Users:Craig:Pictures:Pictures:untitled1:" to mymonth
			on error
				
			end try
		end try
		
		set unknownfolder2 to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & mydate & ":"
		
		try
			alias unknownfolder2
		on error
			try
				make new folder at ("Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth) with properties {name:"untitled2"}
				set nwpath to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & ":"
				set name of folder (nwpath & "untitled2:") to mydate
			end try
		end try
		set mydate1 to day of (current date)
		set mymonth1 to month of (current date)
		set localFolder to "Macintosh HD:Users:Craig:Pictures:eBay Temp:"
		set remoteFolder to ("Macintosh HD:Users:Craig:Pictures:Pictres:" & mymonth1 & mydate1)
		move every file of folder localFolder to folder remoteFolder with replacing
	end tell
	return input
end run
What it basically does is create a folder in the pictures folder with todays month, then creates a folder inside that with the day of the month, then moves all the pictures in there. The only part I'm having trouble with is the last bit where it moves the files. (Fourth to last line.) When running the script, I get:
"Finder got an error: Can't set folder 'Macintosh HD:Users:Craig:pictures:pictures:July21' to every file of folder "Macintosh HD:Users:Craig:pictures:eBay Temp:".

Any ideas? :confused:
 

HexMonkey

Administrator emeritus
Feb 5, 2004
2,240
504
New Zealand
When you append several variables to a folder string, you need to separate them with colons so they are treated as separate folders.

eg
Code:
set unknownfolder2 to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & mydate & ":"
    -->"Macintosh HD:Users:Craig:Pictures:Pictures:July21:"

Should be
Code:
set unknownfolder2 to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & ":" & mydate & ":"
    -->"Macintosh HD:Users:Craig:Pictures:Pictures:July:21:"

Similarly
Code:
set remoteFolder to ("Macintosh HD:Users:Craig:Pictures:Pictres:" & mymonth1 & mydate1)

Should be (note the "Pictres" typo is also fixed)
Code:
set remoteFolder to ("Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth1 & ":" & mydate1)

With the above changes, here's the new code:
Code:
on run {input, parameters}
	tell application "Finder"
		set mydate to day of (current date) as string
		set mymonth to month of (current date) as string
		if exists folder "Macintosh HD:Users:Craig:Pictures:eBay Temp:" then
		else
			make new folder at "Macintosh HD:Users:Craig:Pictures:" with properties {name:"eBay Temp"}
		end if
		if exists folder "Macintosh HD:Users:Craig:Pictures:Pictures:" then
		else
			make new folder at "Macintosh HD:Users:Craig:Pictures:" with properties {name:"Pictures"}
		end if
		
		
		set unknownfolder to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & ":"
		try
			alias unknownfolder
		on error
			try
				make new folder at "Macintosh HD:Users:Craig:Pictures:Pictures:" with properties {name:"untitled1"}
				set name of folder "Macintosh HD:Users:Craig:Pictures:Pictures:untitled1:" to mymonth
			on error
				
			end try
		end try
		
		set unknownfolder2 to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & ":" & mydate & ":"
		
		try
			alias unknownfolder2
		on error
			try
				make new folder at ("Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth) with properties {name:"untitled2"}
				set nwpath to "Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth & ":"
				set name of folder (nwpath & "untitled2:") to mydate
			end try
		end try
		set mydate1 to day of (current date)
		set mymonth1 to month of (current date)
		set localFolder to "Macintosh HD:Users:Craig:Pictures:eBay Temp:"
		set remoteFolder to ("Macintosh HD:Users:Craig:Pictures:Pictures:" & mymonth1 & ":" & mydate1)
		move every file of folder localFolder to folder remoteFolder with replacing
	end tell
	return input
end run
 

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
Woo hoo! :eek:

Thanks so much for the help, I really appreciate it! I've had a bit of applescript experience in the past, but not enough to know that much about dealing with variables in file paths. The script works great now, my mom sends her thanks ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.