
這似乎有效。唯一的問題是它不是遞歸的。
property Location : alias "Macintosh HD:Location"
tell application "System Events" to files of Location whose name extension = "ext"
if the result = {} then tell application "Example" to quit
答案1
您可以使用 Finder 取得全部內容:
set f to POSIX file "/Users/username/folder" as alias
tell application "Finder"
files of entire contents of f where name extension is "torrent"
end tell
如果資料夾有很多文件,使用 find 可能會更快:
do shell script "find ~/folder -name \\*.torrent" is not ""
答案2
嘗試:
set downloadsPath to (path to downloads folder)
tell application "System Events" to files of downloadsPath whose name extension = "torrent"
if the result ≠ {} then tell application "Transmission" to activate