我正在尝试使用AppleScript在查找器中打开一个文件夹。以下是我的代码。我希望在Finder中打开文件夹WorkSpace,但它会打开父文件夹/Volumes/MyMacDrive/Mani并突出显示WorkSpace文件夹。我想要WorkSpace文件夹的内容,但我得到的只是其父文件夹的内容。我错过了什么..?
property the_path : "/Volumes/MyMacDrive/Mani/WorkSpace/"
set the_folder to (POSIX file the_path) as alias
tell application "Finder"
activate
if window 1 exists then
set target of window 1 to the_folder
else
reveal the_folder
end if
end tell发布于 2012-07-19 18:05:12
据我所知,除了在AppleScript中高亮显示该文件夹之外,似乎没有办法打开该文件夹。因此,我使用了:
do shell script "open /Volumes/MyMacDrive/Mani/WorkSpace/"它对我来说工作得很好,但如果我错了,请更新我。
发布于 2012-09-27 00:42:48
实际上,它比看起来的要简单:
tell application "Finder" to open ("/Volumes/MyMacDrive/Mani/WorkSpace/" as POSIX file)或者使用冒号提供AppleScript路径:
tell application "Finder" to open "MyMacDrive:Mani:WorkSpace"这样你就有了一个打开的窗口
发布于 2012-06-29 20:20:31
尝试:
if front Finder window exists then
set target of front Finder window to the_folder
else
open the_folder
end if经过编辑,纳入了jackjr300的更正。Finder窗口是要使用的正确类。
https://stackoverflow.com/questions/11261516
复制相似问题