Applescript: Open a Folder in Finder

拈花ヽ惹草 提交于 2019-12-04 00:23:37
Manikandaraj Srinivasan

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.

user1700898

It's actually simpler than it seems:

tell application "Finder" to open ("/Volumes/MyMacDrive/Mani/WorkSpace/" as POSIX file)

or use colons to give an AppleScript path:

tell application "Finder" to open "MyMacDrive:Mani:WorkSpace"

with that you have an open window

adayzdone

Try:

if front Finder window exists then
    set target of front Finder window to the_folder
else
    open the_folder
end if

Edited to incorporate jackjr300's correction. Finder window is the correct class to use.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!