cwd*_*cwd 5 photoshop applescript
如何使用applescript在photoshop(cs5)中获取当前打开的文件路径?
我在Mac OSX 10.7上使用CS5
我已经尝试了下面的答案,它在Applescript编辑器中给出了以下错误:
error "Adobe Photoshop CS5 got an error: Can’t get document 1.
Invalid index." number -1719 from document 1
Run Code Online (Sandbox Code Playgroud)
更新:我已经在 CS5 和 Mac OS 10.7 中测试了下面的代码,并且可以确认即使简单切换tell application "Adobe Photoshop CS4"到tell application "Adobe Photoshop CS5". 您收到的错误是因为您的目标是文档 1,所以一开始就没有打开文档。您可以使用以下命令轻松检查这一点:
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
Run Code Online (Sandbox Code Playgroud)
旧答案:我还没有 CS5,但这里是 CS4 的,我想 CS5 的版本不会有太大的不同(如果有的话),因为自 CS3 以来 Adobe 在 API 规范化方面做得很好:
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3574 次 |
| 最近记录: |