Applescript 创建新文件夹
我想在苹果脚本中创建一个新的文件夹命令
为什么这个脚本不起作用?
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
I Want to make a new Folder command in apple script
Why dosent this script work?
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用 AppleScript 更直接地完成此操作:
You can do it more directly with AppleScript:
我不知道在 AppleScript 中运行 bash 命令是否作弊,但您也可以这样做:
当您需要在子文件夹尚不存在时动态创建子文件夹时,这很有用:
I don't know if running bash commands within AppleScript is cheating, but you can also do:
Which is useful when you need to create sub folders on-the-fly when they don't exist yet:
注意:这可能会因两个原因而失败;
(1) '~' 陷入单引号中将无法解析。
(2) '/New Folder/' 中的空格会破坏路径。
已解决:
NOTE: This can fail for two reasons;
(1) '~' trapped in singlequote won't parse.
(2) space in '/New Folder/' will break the path.
SOLVED:
您可以直接使用 applescript 脚本模拟击键(“N”和 command 和 Shift),这将在桌面上或打开的 Finder 窗口中创建一个新文件夹。
在脚本下方,您可以在脚本编辑器中测试它,
如果您在“tell process”Finder 下添加,则脚本可以工作
“将最前面设置为 true”
哪个给
You can directly with an applescript script by simulating keystroke on ("N" and command and shift) this will create a new folder on the desktop or in the open Finder window.
Below the script, you can test it in the script editor
Your script works if you add under "tell process" Finder "
"set frontmost to true"
Which give