我在Applecript的工作中相当新,并且想知道是否有人可以帮助我。
我正在编写将执行很多操作的脚本,其中一个将在文件夹中查找具有.mhl扩展名的文件,以便对它们运行终端命令。我将脚本的部分粘贴到下面。现在,除了一个小细节外,这似乎工作得很好。 .mhl文件需要位于我文件夹的第一级。问题是我的文件夹包含包含.mhl的子文件夹。有没有办法告诉这个脚本查看整个文件夹(子文件夹包含)?
非常感谢
set input to "/Source"
tell application "System Events" to set theFiles to POSIX path of (files of folder input whose name contains ".mhl")
repeat with i in theFiles
set filecount to 1
tell application "Terminal"
activate
do script "mhl verify -f " & POSIX path of i & ""
end tell
end repeat
答案 0 :(得分:0)
可能更容易使用find命令,但这是一种AS方法......
set input to POSIX file "/Source"
tell application "Finder" to set theFiles to (files of entire contents of folder input whose name extension = "mhl") as alias list
tell application "Terminal"
if not (exists window 1) then reopen
activate
end tell
repeat with aFile in theFiles
set filePath to aFile's POSIX path
tell application "Terminal"
do script "mhl verify -f " & quoted form of filePath in window 1
end tell
end repeat