开发者

How can I get the currently open file's path in photoshop (cs5) with applescript?

How can I get the currently open file's path in photoshop (cs5) with applescript?

I'm using CS5 on Mac OSX 10.7

I've tried the answer below and it gives the following error in the Applescript Editor:

error "Adobe P开发者_JAVA百科hotoshop CS5 got an error: Can’t get document 1.
Invalid index." number -1719 from document 1


UPDATE: I have tested the code below in CS5 and Mac OS 10.7 and can confirm that this works even with a simple switch of tell application "Adobe Photoshop CS4" to tell application "Adobe Photoshop CS5". The error that you are getting is the result of there either not being a document open in the first place since you are targeting document 1. You can easily check for this with the following:

tell application "Adobe Photoshop CS5"
    set documentCount to count documents
    if documentCount > 0 then
        set theDocument to document 1
        set theFilePath to file path of theDocument
        return theFilePath
    else
        -- no documents open. what to do?
    end if
end tell

OLD ANSWER: I don't have CS5 (yet), but here it is for CS4, and I imagine CS5's version won't be too different, if at all, since Adobe has done a good job normalizing the API since CS3:

tell application "Adobe Photoshop CS4"
    set theDocument to document 1
    set theFilePath to file path of theDocument
    return theFilePath
end tell
--> Result: Macintosh HD:path:to:file:filename.ext
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜