脚本编辑器打开文件夹并提问以删除它

时间:2017-12-04 16:48:35

标签: macos applescript finder

我希望程序打开一个文件夹然后显示一个文本来删除这个文件夹,但是我无法让它工作。任何帮助表示赞赏。

    on opening folder theResponse
    tell application "Finder"
    set theName to name of theResponse
    activate
    display alert "Attention!" message "The folder" & theName & " was opened."
    set question to display dialog "Do you want to delete this folder?" buttons {"No", "Yes"} default button "No"
    set answer to button returned of question
    if answer is equal to "Yes" then
    set sourceFolder to theName
    move sourceFolder to the trash
        end tell
    end opening folder

1 个答案:

答案 0 :(得分:0)

theName是文件夹名称 - 字符串 - 例如PicturesMovies。您需要对theResponse

的文件夹(Finder说明符或别名)的引用

删除

<击>

<击>
set sourceFolder to theName

<击>

并更改

move theResponse to the trash