问题描述
我正在尝试使用 AppleScript 在 Finder 中打开一个文件夹.以下是我的代码.我希望文件夹 WorkSpace
在 Finder 中打开,但它会打开父文件夹 /Volumes/MyMacDrive/Mani
并突出显示 WorkSpace
文件夹.我想要 WorkSpace
文件夹的内容,但我得到的只是它的父文件夹的内容.我在这里错过了什么..?
I m trying to open a folder in Finder using AppleScript. The following is my code. I want the folder WorkSpace
to open in Finder, but it opens the Parent Folder /Volumes/MyMacDrive/Mani
and highlights the WorkSpace
folder. I want the contents of WorkSpace
folder, but all I'm getting is its Parent Folder's Contents. What am i missing here ..?
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
推荐答案
据我搜索,似乎没有办法打开文件夹,而只能在 AppleScript 中突出显示文件夹.所以我用过:
As far as I've searched, there seems to be no way to open the folder rather than just highlighting the folder in AppleScript. So I have used:
do shell script "open /Volumes/MyMacDrive/Mani/WorkSpace/"
它对我来说很好,但如果我错了,请更新我.
It worked fine for me but please update me if i'm wrong.
这篇关于Applescript:在 Finder 中打开文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!