如何使用 AppleScript 从指定文件夹打开随机文件?

如何使用 AppleScript 从指定文件夹打开随机文件?

这是我现在的代码:

tell application "Finder"
get some file of (folder (POSIX file "Desktop/musics"))
end tell

答案1

tell application "Finder" to open some file in the folder ¬
    (POSIX file "/Users/%you%/Desktop/musics")

需要%you%用用户主目录的名称替换(它看起来像发现者)。

答案2

这是另一种选择。

tell application "Finder"
    set someFile to some file of folder ((path to desktop as text) & "musics")
    open someFile
end tell

相关内容