AppleScript返回Null()

时间:2014-01-09 23:39:55

标签: applescript

当我运行AppleScript时,我收到错误(null)。我唯一能想到的是文件路径格式不正确。任何帮助将不胜感激。

on run {input, parameters}

    set picFolder to alias "Users:cd:Dropbox (Personal):Camera Uploads:"
    set screenshotFolder to alias "Users:cd:Dropbox (Personal):Camera Uploads:Screenshots:"

    tell application "System Events"
        set photos to path of files of picFolder whose kind is "Portable Network Graphics image"
    end tell

    set screenshots to {}
    repeat with imgPath in photos
        set imgAlias to alias imgPath
        tell application "Image Events"
            set img to open imgPath
            if ((dimensions of img = {640, 1136}) or (dimensions of img = {640, 960}) or (dimensions of img = {1024, 768})) then
                set end of screenshots to imgAlias
            end if
            close img
        end tell
    end repeat

    tell application "Finder"
        move screenshots to screenshotFolder
    end tell


    return input
end run

1 个答案:

答案 0 :(得分:0)

主脚本适用于我,但如果我按照脚本编辑器中的方式运行它,则不行。我必须注释掉{input, parameters}return input,因为运行处理程序(在此上下文中)不能接受参数(或者您可以更改处理程序的名称)。如果我这样做似乎没有问题(除了明显缺乏纠错,例如,如果文件已经存在,等等)。您可以使用运行处理程序的参数,但是您无法在脚本编辑器中以这种方式测试它(我假设您最终要从命令行发送参数)。