![如何使用 AppleScript 从指定文件夹打开随机文件?](https://linux22.com/image/1573569/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20AppleScript%20%E4%BB%8E%E6%8C%87%E5%AE%9A%E6%96%87%E4%BB%B6%E5%A4%B9%E6%89%93%E5%BC%80%E9%9A%8F%E6%9C%BA%E6%96%87%E4%BB%B6%EF%BC%9F.png)
这是我现在的代码:
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