需要一个简单的Applescript函数帮助创建突然停止工作的项目文件夹

时间:2013-10-29 14:11:53

标签: applescript

我使用一个简单的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

如果有人能够阐明为什么这种情况已经停止工作,或者能够就如何解决这个问题提供指导,那么我将非常感激!

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

提前感谢大家。

马特

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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

set {jobnumber, button_pressed} to {text returned, button returned} of result