two variables in applescript within automator..

Hi I have two variables which have been added within automator but then I have to use them within an applescript.

Its basically searching for a folder within a volume. The folder is an automator variable (Input_DivCode) and the same for the volume (CS_Area_ClientFolder).

Im almost there, I’m just stuck on the searching part. Any help or pointers appreciated…

Thanks.

on run {input, parameters}
	set input to (input as text)
	tell application "Finder"
		set Input_DivCode to the result
		set CS_Area_ClientFolder to the result
		if (folder Input_DivCode of folder CS_Area_ClientFolder exists) = true then
			display alert "The Job folders already exist!" message "If you press continue you will overwrite the existing folders!." buttons {"Cancel", "Continue"} default button 1
			if button returned of result = "Continue" then
				display dialog ("The  Job folders already exist are you absolutely sure you want to overwrite them! It will wipe any work stored on them. You can not undo this action") buttons {"Cancel", "Continue"} default button 1 with icon stop
			end if
		end if
	end tell
end run

Ok … Im trying to test why this isn’t working so i have just set it up in Applescript getting the variables from inputs…

Im stuck at the searching part still. If you swap the true and false over it continues but not if it finds a folder of the same name. Any advice?

Thanks

tell application "Finder"
	display dialog "Please enter the DivCode" default answer "1234"
	set Input_DivCode to result
	choose folder with prompt "And where do you want it to go?"
	set CS_Area_ClientFolder to result
	
	if (result of Input_DivCode of CS_Area_ClientFolder exists) = false then
		display alert "The Job folders already exist!" message "If you press continue you will overwrite the existing folders!." buttons {"Cancel", "Continue"} default button 1
	else
		display alert "All Good"
	end if
end tell

Just missing the obvious… This works in stand alone Apple script but not inside automator…

As I get Can’t make “current application” into type integer. Any ideas how to get round this?

tell application "Finder"
	display dialog "Please enter the DivCode" default answer "1234"
	set Input_DivCode to the text returned of the result
	choose folder with prompt "And where do you want it to go?"
	set CS_Area_ClientFolder to result
	if (exists folder Input_DivCode of entire contents of CS_Area_ClientFolder) then
		display alert "The Job folders already exist!" message "If you press continue you will overwrite the existing folders!." buttons {"Cancel", "Continue"} default button 1
	else
		display alert "All Good"
	end if
end tell

Thanks Rob

I have just found the answer, it’s more of an automator thing, but might help others…
http://moonsharke.wordpress.com/2011/06/03/multiple-variables-for-automators-run-applescript-action/