Applescript制作新文件夹

志不强者智不达,言不信者行不果。这篇文章主要讲述Applescript制作新文件夹相关的知识,希望能为你提供帮助。
我想在Apple脚本中创建一个新的Folder命令
为什么这个脚本不起作用?

tell application "Finder" activate end tell tell application "System Events" tell process "Finder" tell menu bar 1 tell menu bar item "File" tell menu "File" click menu item "New folder" end tell end tell end tell end tell end tell

答案您可以使用AppleScript直接执行此操作:
tell application "Finder" set p to path to desktop -- Or whatever path you want make new folder at p with properties {name:"New Folder"} end tell

另一答案
tell application "Finder" activate end tell tell application "System Events" tell process "Finder" tell menu bar 1 tell menu bar item "File" tell menu "File" click menu item "new folder" end tell end tell end tell end tell end tell--you capitalize the N in new folder the new folder button is not capped.

另一答案我不知道在AppleScript中运行bash命令是否作弊,但您也可以这样做:
do shell script "mkdir '~/Desktop/New Folder'"

当您需要在尚不存在的情况下即时创建子文件夹时,这非常有用:
do shell script "mkdir -p '~/Desktop/New Folder/Bleep/Bloop'"

另一答案注意:这可能由于两个原因而失败; (1)被困在单引号中的'?'不会解析。 (2)'/ New Folder /'中的空格将打破路径。
do shell script "mkdir -p '~/Desktop/New Folder/Bleep/Bloop'"

解决了:
do shell script "mkdir -p ~/Desktop/" & quoted form of "New Folder/Bleep/Bloop"

另一答案您可以通过模拟按键(“N”和命令和移位)直接使用applescript脚本,这将在桌面或打开的Finder窗口中创建一个新文件夹。
在脚本下方,您可以在脚本编辑器中对其进行测试
tell application "System Events" to tell process "Finder" set frontmost to true keystroke "N" using {command down, shift down} end tell

【Applescript制作新文件夹】如果你在“告诉过程”下添加Finder“”设置最前面的“真实”,你的脚本是有用的
tell application "System Events" tell process "Finder" set frontmost to true tell menu bar 1 tell menu bar item "File" tell menu "File" click menu item "New folder" end tell end tell end tell end tell end tell


    推荐阅读