脚本编辑器创建文件夹并命名它

时间:2017-11-02 21:56:46

标签: macos applescript finder

所以我一直在尝试编写一个AppleScript脚本来创建一个带有用户输入的文件夹,但不幸的是我无法使其正常工作。任何帮助表示赞赏。

set theResponse to display dialog "Enter the name of folder" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"
display dialog "Name of the folder:  " & (text returned of theResponse) & "."
tell application "Finder"
    make new folder at desktop with properties {name:"theResponse"}
end tell

1 个答案:

答案 0 :(得分:1)

以下是您的代码的修改版本:

set theResponse to text returned of (display dialog "Enter the name of folder" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue")
display dialog "Name of the folder:  " & theResponse & "."
tell application "Finder"
    make new folder at desktop with properties {name:theResponse}
end tell

在原始代码{name:"theResponse"}中,引号为"theResponse",字面上theResponse不是the text returned

所以,在代码的第一行,我开始将theResponse 变量设置为the text returned,所以不必是稍后在脚本中引用。

因此代码第二行中的(text returned of theResponse)现在设置为theResponse,其中包含变量的

现在到了make new folder时,name 属性theResponse,没有引号,而且已从代码的第一行包含the text returned

相关问题