Macos 脚本编辑器创建文件夹并命名它
所以我一直在尝试编写一个AppleScript脚本,用用户输入创建一个文件夹,但不幸的是,我无法让它工作。感谢您的帮助Macos 脚本编辑器创建文件夹并命名它,macos,applescript,finder,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: "
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
以下是代码的修改版本,可以正常工作:
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}中,响应用引号括起来,它实际上是响应,而不是返回的文本
因此,在第一行代码中,我首先将响应变量设置为返回的文本,这样以后就不必在脚本中引用它了
因此,第二行代码中返回的响应文本现在设置为仅响应,其中包含该变量的值
现在,当需要创建新文件夹时,name属性是响应的值,不带引号,并且它已经包含从第一行代码返回的文本 你用什么来写剧本?bash,node.js…?@StealthtenInja:在我看来,这就像是脚本编辑器的默认语言AppleScript。请单击问题下的编辑,选择代码并单击代码格式图标{}