好吧,如果我想从文件夹在我的 Mac 上,我可以成功使用以下脚本:
tell application "Finder"
open some file of (folder ("Users:chris:Desktop:photoAlbum") of startup disk)
end tell
但是,我不确定当我想从卷/磁盘映像我已经安装。该卷位于/用户/克里斯/下载/photoAlbum.dmg但以下操作不成功:
tell application "Finder"
open some file of (folder ("Users:chris:Downloads:photoAlbum.dmg") of startup disk)
end tell
我应该使用什么脚本来执行后者?
答案1
假设有问题的磁盘是不是已经安装,然后:
tell application id "com.apple.Finder"
set downloads to the path to the downloads folder
set _files to a reference to files in downloads
set _disks to the name of every disk
set _dmgs to the name of the _files whose name extension = "dmg"
set _selection to choose from list of _dmgs with multiple selections allowed
open (the _files whose name is in the _selection)
set _volumes to a reference to (the disks whose name is not in _disks)
repeat until (_volumes exists)
delay 1
end repeat
open some file in some disk of (get _volumes)
end tell