所以我一直在尝试编写一个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
答案 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
。