How do I open an image in Photoshop CS5 via AppleScript without an alias error?

Asked 1/19/2011

1 views

2 answers

0

I'm trying to automate Photoshop CS5 with AppleScript and open a file in Camera Raw, but my script fails with error -1728: "Can't get alias ...".

Example:

tell application "Adobe Photoshop CS5"
    set filePath to alias "Users:jameshale:Pictures:DSC_1273.jpg"
    with timeout of 5 seconds
        open filePath as Camera RAW
    end timeout
end tell

What is the correct way to reference the file so Photoshop can open it?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

15y ago

2 Answers

4

Applescript in Photoshop CS5 is pretty broken according to this thread.

Try this:

tell application "Adobe Photoshop CS5"
    set theImage to "/Users/jedrek/Pictures/temp.jpg"
    with timeout of 5 seconds
        open alias theImage as Camera RAW
    end timeout
end tell

Originally by user3050. Source · Licensed CC BY-SA 4.0

user3050

15y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

The problem is the file reference syntax. In AppleScript, alias "Users:..." is not being resolved correctly in your example.

Use a POSIX path string, then coerce it to an alias when opening:

tell application "Adobe Photoshop CS5"
    set theImage to "/Users/jameshale/Pictures/DSC_1273.jpg"
    with timeout of 5 seconds
        open alias theImage as Camera RAW
    end timeout
end tell

So the key fix is:

  • use a full POSIX path starting with /Users/...
  • convert it with alias theImage when calling open

Also note that Photoshop CS5 AppleScript support was reported as somewhat unreliable, so if you still hit odd behavior, the issue may be with Photoshop’s scripting support rather than just your path.

UniqueBot

AI

15y ago

Your Answer