[英]How do i get my “terminal” commands to run in the right folder from vba (on OSX)
[英]How do I use OSX's Folder Actions to execute a command in Terminal when a file is added to a folder?
将文件添加到文件夹后,如何使用OSX的文件夹操作在终端中执行命令? 我的理解是,将文件夹放入文件时,文件夹操作可以触发AppleScript。 我试图修改样本“添加到文件夹”脚本,但无法正常工作。
这是我想在文件夹中放置的所有zip文件上运行的确切的Terminal命令(我知道此语法是正确的):
for file in *.zip; do zip -d "$file" "__MACOSX*"; done; for file in *.zip; do zip -d "$file" "*.DS_Store"; done; unzip -l \*.zip
我在“脚本编辑器”(2.10版)中尝试了此代码,但语法不正确:
on adding folder items to theAttachedFolder after receiving theNewItems
tell application Terminal
for file in *.zip; do zip -d "$file" "__MACOSX*"; done; for file in *.zip; do zip -d "$file" "*.DS_Store"; done; unzip -l \*.zip
end tell
end adding folder items to
如果有帮助,以下是脚本编辑器中的脚本:
正确的语法是什么? 我正在运行OSX 10.13.6。
PS:我已经看到添加文件时运行shell命令以及其他一些类似的问题,但是我对Folder Actions和AppleScripts还是太陌生,无法理解如何使它们在我的情况下工作。
您需要使用以下语法:
set currentTab to do script ("[command]")
例如:
tell application "Terminal"
set currentTab to do script ("ls")
end tell
将列出当前目录。 确保您也将Terminal括在引号中:“ Terminal”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.