1

我使用一个简单的 Applescript 函数来为通过工作室的工作创建客户端项目文件夹。

这是一个久经考验且值得信赖的脚本,已经使用了大约 7 年左右,并且运行良好。

由于某种原因,脚本似乎突然停止工作,并且不会在最终文件夹层次结构中包含作业编号。它现在创建一个名为“OK OK”的文件夹,其中包含正确的文件夹结构,但没有作业编号。

我确实尝试了所有方法,但现在我心情沉重,大脑疲倦,正在寻求帮助!

这是我当前的脚本:

tell application "Finder"
    activate

    set the jobnumber to "[jobnum] "
    set the jobtitle to "[jobtitle] "


    repeat
        display dialog "Enter the job number:" default answer the jobnumber buttons {"Cancel", "OK"} default button 2
        copy the result as list to {the jobnumber, the button_pressed}
        if the jobnumber is not "" then exit repeat
    end repeat


    repeat
        display dialog "Enter the job title:" default answer the jobtitle buttons {"Cancel", "OK"} default button 2
        copy the result as list to {the jobtitle, the button_pressed}
        if the jobtitle is not "" then exit repeat
    end repeat

    set the jobtitle to jobnumber & " " & jobtitle

    set deskpath to desktop

    make new folder at deskpath with properties {name:jobtitle}
    make new folder at folder jobtitle of deskpath with properties {name:jobnumber & " Admin"}
    make new folder at folder jobtitle of deskpath with properties {name:jobnumber & " Final Artwork"}
    make new folder at folder jobtitle of deskpath with properties {name:jobnumber & " Links"}
    make new folder at folder jobtitle of deskpath with properties {name:jobnumber & " PDFs"}
    make new folder at folder jobtitle of deskpath with properties {name:jobnumber & " Resources"}
    make new folder at folder jobtitle of deskpath with properties {name:jobnumber & " Visuals"}

    make new folder at folder (jobnumber & " PDFs") of folder jobtitle of deskpath with properties {name:jobnumber & " Old PDFs"}

    make new folder at folder (jobnumber & " Admin") of folder jobtitle of deskpath with properties {name:jobnumber & " Supplier Estimates"}

    make new folder at folder (jobnumber & " Links") of folder jobtitle of deskpath with properties {name:jobnumber & " Workings & Resources"}

    make new folder at folder (jobnumber & " Visuals") of folder jobtitle of deskpath with properties {name:jobnumber & " Visual Links"}

    make new folder at folder (jobnumber & " Resources") of folder jobtitle of deskpath with properties {name:jobnumber & " Supplied Files"}

end tell

如果有人能阐明为什么这只是停止工作,或者愿意就如何解决这个问题提供指导,那么我将非常感激!

我不介意它是否是一个全新的脚本......我只需要它再次工作!

提前感谢大家。

马特

4

2 回答 2

0

基本上,正如 Darrick Herwehe 所说,对话框的结果是先返回按钮,然后再返回文本。所以你的变量得到的结果与你想象的相反。这是我如何获得显示对话框的结果。因此,我将使用它来确保我知道返回结果的顺序,而不是“复制结果...”行。或者您可以按照 Darrick Herwehe 的建议进行操作,并且只返回文本。

set {jobnumber, button_pressed} to {text returned, button returned} of result
于 2013-10-29T15:37:47.430 回答
0

看起来您的对话框正在将您的变量设置button returned为显示对话框而不是text returned. 您应该使用返回的记录来获取您的信息,而不是创建一个可能会更改顺序的列表。

您可以将重复循环更改为以下内容,这将确保您从对话框中获得正确的值:

repeat
    set the jobnumber to text returned of (display dialog "Enter the job number:" default answer the jobnumber buttons {"Cancel", "OK"} default button 2)
    if the jobnumber is not "" then exit repeat
end repeat


repeat
    set the jobtitle to text returned of (display dialog "Enter the job title:" default answer the jobtitle buttons {"Cancel", "OK"} default button 2)
    if the jobtitle is not "" then exit repeat
end repeat
于 2013-10-29T15:06:36.217 回答