Odd PS 7.0.1 behavior during script

I’m trying to fumble my way through my first real AppleScript, and to keep from pestering the one person I know with all of my questions, I am hoping to get some help here.

When trying to activate an action in PS with a script, the action will perform perfectly on a currenty open document when I use:

do script "Fill"

But, if I try to tell PS to use other files, even directly with:

do script "Fill" with "MacHD:Folder:File"

Photoshop suddenly loses the action, it is completely removed from the app as if it never existed, and I get an error saying that the droplet could not be run due to a disk ewrror.

Does anybody know why this is happening, is it me, a bug with PS, or what??

Thanks for your help!

Edit: I found an old script on this site for running an action in PS 5.5 whcih was structured differently than what I saw in the PS 7 dictionary, so I tried the following:

tell application "Adobe Photoshop 7.0"
			open "MacHD:Folder:File"
			do script "Fill"
end tell

It didn’t work either, but I got a different error- “can’t make some data into the expected type.” Don’t know if that sheds light anywhere that may be of additioanl assistance, but there it is anyway.

I’m going to refer my comments to your final code example:

tell application "Adobe Photoshop 7.0" 
         open "MacHD:Folder:File" 
         do script "Fill" 
end tell

You’ll need to give photoshop a file reference
In your example, the file reference is incomplete.
The code below works well for me.


tell application "Adobe Photoshop 7.0"
	open file "MacHD:Folder:file"
	do script "Fill"
end tell

That worked, thank you T.J.

What structure is the PS dictionary suggesting when it says the following?

	do script  string  -- Name of action or actual action to execute
		[with  a list of alias]  -- List of files on which to run the action.  If this parameter is not present, the script is run on the active document *for use only by droplets*

Here’s how it works:

do script - This portion is the basic command.
string - This should be the name of your action, as you created it in PS.
[with a list of alias] - The brackets enclose what are called optional parameters. These are additional specifics you can give along with the command, but they aren’t required for basic functionality.

In this case, it means you can give your script a pre-defined list of files you want the ‘do script’ command run on.

So, here’s a full example, using the optional parameter:

do script "my_action" with {alias "Macintosh HD:some_folder:file1.jpg", alias "Macintosh HD:some_folder:file2.jpg", alias "Macintosh HD:some_folder:file3.jpg"}

Thanks again T.J., the syntax works, but this strucure gives me the problem I first brought up with Photoshop 7.0.1 giving an error and the action being deleted from the application. Very strange.

For the record, this is the exact script I tried.

tell application "Adobe Photoshop 7.0"
	do script "BDS prep" with ["Sean:Bulletin Process:EPSs to convert:test1.EPS"]
end tell

Ok, the problem in your example above is 2-fold:

  1. the optional parameter is a alias list. Lists are enclosed in ‘curly’ brackets. {}
  2. Your alias reference is incomplete. So, this:
do script "BDS prep" with ["Sean:Bulletin Process:EPSs to convert:test1.EPS"]

should actually read like this:

do script "BDS prep" with { alias "Sean:Bulletin Process:EPSs to convert:test1.EPS"}

In PS 7 the command is now do action not do script and you need to specify the set the action is from. This is a template for running an action on a selection of files from the finder which might work for you:

tell application "Finder"
	activate
	set the selected_items to the selection
	if the selected_items is {} then
		beep
		display dialog "Please select items before running this script." buttons {"Cancel"} default button 1
	end if
	repeat with aFile in selected_items
		set myFile to aFile as string
		tell application "Adobe Photoshop 7.0"
			activate
			--save options from the dictionary Save Formats Suite, adjust as needed
			set myOptions to {class:Photoshop save options, embed color profile:false, save alpha channels:true}
			open aFile
			tell current document
				--commands go here
				--the action and action's set need to be specified
				do action "Your Action Name" from "Your Action Set"
				save in file myFile as Photoshop format with options myOptions appending no extension without copying
				close
				
			end tell
		end tell
	end repeat
	beep
end tell

I had tried regular and curly brackets previously and it didn’t seem to make a difference, I just wasn’t sure which was right, now I know. After making the correction and adding the alias reference, the action called still ends up being deleted from PS, like before. I am trying to sort through Rob’s script now to see how that goes. Sorry for being so sporadic in responding to this thread, I just dont get much free time at work. Catch-22 I suppose, if i had more free time, I could work on the script, which when finished will give me more free time. Thanks again.

Okay Rob, thanks for posting this, now let the Stupid Questions? begin. You mention a dictionary called “Save Formats Sweet,” where can I find this? The script as posted wont pass syntax check, and I don’t know what teh proper parameters are to put in there. I tried searching this site, and came up dry. Thanks.

I checked the script and it compiled for me (I’m in OSX10.2.3). If you cut and paste into script editor make sure the long lines don’t wrap to 2 lines–when you try to compile the script editor will show an error at those lines.

You can get to Photoshop’s or any application’s dictionary from the Script Editor’s File>Open Dictionary dialog–just select the application.

When you create an action in PS it has a name and is part of a set (sets are folder icons in the Actions palette) If you are trying to run a Photoshop Action from within a script the name of the action and it’s set follow the do action command.

I am using 10.2.3 and Script Editor 2.0 (v20). I have been using the Photoshop 7.0.1 dictionary, I thought you were referencing something different because my dictionary doesn’t have the Save Formats Suite, only the Required Suite and Photoshop Suite (which contains Events, and ‘do script’ as a sub-category of that).

When I try to compile your script, it balks on “options” in the line “set myOptions to {class:Photoshop save options, embed color profile:false, save alpha” and gives me the error “Expected “given”, “with”, “without”, other parameter name, etc. but found identifier.”

Also, regarding the action/set spec, my Script Editor refuses to accept “do action” and will only validate “do script” and if I try to add “from” to “do script”, it will not validate that either.

I don’t know why I am having trouble with things that are working for other people, it’s a bit frustrating. I don’t have any other system/application troubles at all, so it isn’t like I have problems in other areas with my machine. I have also replicated the problem with photoshop actions dissapearing on two other machines, one in the office and the other at home, so I know I’m not completely crazy.

Oh I see what’s going on–either you don’t have the Photoshop scriping plug-in installed or it’s not working. You need this:
[url]http://www.ADOBE.com/support/downloads/detail.jsp?ftpID=1535

[/url]

Holy crap, the fog has lifted. Thanks.

So I finally feel like I am making progress, but have hit another problem. In working with Rob Day’s script, although it seems to me that Photoshop is the app being told to open a file previosuly selected by the Finder, the Finder is trying to open it. This makes InDesign launch or come to the front, since it is the source of the EPS file, and it also makes Photoshop not have anything to run teh action on, since the file is not open in PS. Here is the script as I am using it, where have I gone wrong?

tell application "Finder"
	activate
	set the selected_items to the selection
	if the selected_items is {} then
		beep
		display dialog "Please select items before running this script." buttons {"Cancel"} default button 1
	end if
	repeat with aFile in selected_items
		set myFile to aFile as string
		tell application "Adobe Photoshop 7.0"
			activate
			open aFile as {class:EPS open options, constrain proportions:yes, height:2200, mode:grayscale, resolution:200, use antialias:yes, width:1700}
			tell current document
				--commands go here 
				--the action and action's set need to be specified 
				do action "BDS prep" from "BDS"
				set myOptions to {class:TIFF save options, byte order:IBM PC, image compression:none}
				save in file myFile as Photoshop format with options myOptions appending no extension without copying
				close
			end tell
		end tell
	end repeat
	beep
end tell

I’m not good enough to completely get this for you, but you don’t have the options exactly right. Should be:


as EPS with options {class:EPS open options, constrain proportions:true, height:pixels 2200, width:pixels 1700, mode:grayscale, resolution:200, use antialias:true}

This works for a single file:


tell application "Adobe Photoshop 7.0"
	set myFilePath to alias "Path to File here"
	open myFilePath as EPS with options {class:EPS open options, constrain proportions:true, height:pixels 2200, width:pixels 1700, mode:grayscale, resolution:200, use antialias:true}
	end tell

but when you correct the options in my script you get a Photoshop error "can’t get pixels 2200’ maybe somebody can help with that. There is also a Photoshop scripting forum on Adobe’s site.