Pass variable from applescript to automator

Hi All,

At the begining of a workflow I’m making I would like the user to be presented with a dialog generated by the following applscript.


on run {input, parameters}
	(* This sets the Job Folder for other steps *)
	choose folder with prompt "Choose a job folder to proof to the web:"
	set jobFolder to result
	
end run

The automator steps following the above code, two rename finder items steps, do not seem to recognize the selected folder.

OR

Should I use and automator step “Ask for Finder Items” to select the folder and pass it on to an applescript later in the workflow. I have an applescript later in the workflow that needs the variable jobFolder to represent the folder that was selected.

I don’t want the user to be presented with two different dialogs to select the same folder.

Any Suggestions?

Thanks,
MT

Model: G5 2.0gHz DualCore Power PC
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

I’m guessing that Automator is expecting a list:

on run {input, parameters}
	(* This sets the Job Folder for other steps *)
	choose folder with prompt "Choose a job folder to proof to the web:"
	return {result}
end run

Hi MT,

you should return the value (in this case the folder) like this

on run {input, parameters}
	(* This sets the Job Folder for other steps *)
	return {choose folder with prompt "Choose a job folder to proof to the web:"}
end run

A variable like jobfolder defined within a handler doesn’t “exist” outside

Hi Stephan and Bruce,

While both of your scripts return the path to the folder the next automator step, ( Filter Finder Items ), does not seem to look at the contents or sub directories contents and only looks at the object itself ( the folder that was selected ). I guess I assumed if I passed a folder path the the Filter Finder Items step it would look at all items contained inside to see if they meet the criteria set in Filter Finder Items. Maybe I just need to applescript the the two renaming steps.

I need to look in a specified folder for any jpeg images that end in “tn" then add "tn” to the begining of the name then remove “_tn” from the end of the name and retain the extension. Example “image_001_tn.jpg” would turn into “tn_image_001.jpg”. If I could do that in applescript I could eleminate the two automater renaming steps between the begining, the script at the begining of this post and the next applescript section which also needs the path of the folder selected. Renaming files in applescript like that is beyond me.
Here is more of the script.


choose folder with prompt "Choose a job folder to proof to the web:"
	set jobFolder to result
	set button_pressed to ""
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to " "
	set clientName to every text item of (name of (info for jobFolder))
	set jobNumber to first item of result
	set clientName to (items 2 through -1 of clientName) as string
	set AppleScript's text item delimiters to ASTID
	set webFolder to ((jobFolder as string) & "Processed:Web_Proofs")
(* Insert code to rename images in webFolder that meet the criteria *)

	try
--Renames folder webFolder for uploading
		set webFolder to ((jobFolder as string) & "Processed:Web_Proofs") as alias
		tell application "Finder" to set name of result to ("Job_" & jobNumber)
	on error
		set webFolder to ((jobFolder as string) & "Processed:Job_" & jobNumber) as alias
	end try
-- The rest of the script is not relevent to this section

What are your suggestions?

Many Thanks!
Mark

No, it’s filtering the input and passing it on. However, the Finder does have a Get Folder Contents action that should work for you.

The “Get Folder Contents” action did properly look at the contents and accept the selected folder from the applescript however I need the folder that is selected in the first script to make it to a second script later in the workflow. Is that even possible? It seems the rename finder items action will not pass on any variable from the first applescript. I think I’ll have to use applescript to handle the name changing also otherwise I’ll still have the user selecting the same folder twice. If I can rename the images in applescript then I don’t need to filter file types because the folder it will be looking in will always only have JPEG’s in it.

I need to do the following for every file that ends with “_tn”

  1. add “tn_” to the begining of the name
    2)remove “_tn” from the end of the name and retain the extension.

Example “image_001_tn.jpg” would turn into “tn_image_001.jpg”.

I may need to start a new post in the Applescript forum.

Thanks,
Mark