Man*_*san 13 directory applescript finder
我试图使用AppleScript在Finder中打开一个文件夹.以下是我的代码.我希望文件夹WorkSpace在Finder中打开,但它会打开父文件夹/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
Run Code Online (Sandbox Code Playgroud)
Man*_*san 18
据我搜索过,似乎无法打开文件夹,而只是在AppleScript中突出显示该文件夹.所以我用过:
do shell script "open /Volumes/MyMacDrive/Mani/WorkSpace/"
Run Code Online (Sandbox Code Playgroud)
它对我来说很好,但如果我错了请更新我.
小智 14
它实际上比看起来更简单:
tell application "Finder" to open ("/Volumes/MyMacDrive/Mani/WorkSpace/" as POSIX file)
Run Code Online (Sandbox Code Playgroud)
或使用冒号提供AppleScript路径:
tell application "Finder" to open "MyMacDrive:Mani:WorkSpace"
Run Code Online (Sandbox Code Playgroud)
你有一个开着的窗户
尝试:
if front Finder window exists then
set target of front Finder window to the_folder
else
open the_folder
end if
Run Code Online (Sandbox Code Playgroud)
编辑以纳入 jackjr300 的修正。Finder 窗口是要使用的正确类。
| 归档时间: |
|
| 查看次数: |
36743 次 |
| 最近记录: |