Applescript - 找不到捆绑资源

时间:2011-12-23 02:00:59

标签: scripting applescript photoshop batch-processing photoshop-script

我正在尝试为Photoshop编写一个Applescript Droplet,用于调整大小并为多张照片添加水印。我想捆绑水印图像并保存为应用程序,以便我可以在我的组织中分发它,但我似乎无法让脚本看到捆绑的资源。

我将“watermark.png”图片拖到“Bundle Contents”侧边栏,并使用以下文件处理语句:

on process_item(this_item)
    set myPath to alias this_item as text
    tell application "Adobe Photoshop CS5.1"
        open file myPath
        set thisDocument to current document
        set ruler units of settings to pixel units
        resize image thisDocument width 640
        set wmPath to path to resource "watermark.png"
        open file wmPath
    end tell
end process_item

但我总是收到以下错误:

Resource not found.

我是否必须做一些特别的事情以确保脚本可以找到捆绑的资源?

1 个答案:

答案 0 :(得分:1)

这是因为你要求应用程序“Photoshop”找到资源。它不知道该怎么做。

要解决此问题,请将行set wmPath to path to resource "watermark.png"移到块tell application之外(例如,在行tell application "Adobe Photoshop CS5.1"之前), 或将其更改为:

tell me to set wmPath to path to resource "watermark.png"