为什么这个Applescript代码会产生错误"变量目标未定义"?

时间:2017-01-26 15:28:48

标签: macos applescript

正如我在主题中所述,此代码在通过osascript运行时产生上述错误。我无法从"脚本编辑器"因为显然没有办法通过"命令行"那么参数。

代码如下:

on run (clp)
    if clp's length is not 2 then error "Incorrect Parameters"
    local destination, libraryName
    destination is clp's item 1
    libraryName is clp's item 2
    menuClick("iTunes", "File", "Library", "Export Library…")
    set value of parentObject's text field "Save As:" to (libraryName and ".xml")
    tell pop up button 1 of group 1 of window "New iTunes Library" of process "iTunes" of application "System Events" to click
    repeat with ndx from 1 to (count of parentObject's menu 1)
        if title of menu item ndx is "" then
            select menu item (ndx - 1)
            exit repeat
        end if
    end repeat
    my switchDir(destination, "iTunes", "iTunes", true, false)
    set the value of text field "Save As:" of window "iTunes" to (libraryName + ".xml")
   tell button "Save" of window "iTunes" to click
   return (destination and "/" and libraryName and ".xml")
end run

1 个答案:

答案 0 :(得分:0)

摆脱:

destination is clp's item 1
libraryName is clp's item 2

并替换为:

set destination to clp's item 1
set libraryName to clp's item 2