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



所以我一直在尝试编写一个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
下面是可以

工作的代码的修改版本:

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

最新更新