(繁體中文翻譯在底下)

I would like to bring the “Go to Parent Directory” feature to my Mac OS X’s Finder, which is available since Windows 95.

Although there are already many solutions that you may found with Google (e.g. this, this and this), I still want to make it myself.

All the three solutions are written in AppleScript, calling the built-in AppleScript functions of Finder.  However I think it would be faster if we just trigger the Menu Item.

Mac OS X Finder Go to Enclosing Folder English

After I studied an article which teaches you how to trigger a Menu Item, I made one myself, which is Leopard Only:

  1. Download here → http://dl.getdropbox.com/u/159570/works/goToEnclosingFolder.zip
  2. If your OS X  is not in English, open goToEnclosingFolder.app with Script Editor, then modify the respective menu item titles in the source code, and save it.
  3. Then drag the goToEnclosingFolder.app to the Toolbar of the Finder and enjoy it.

Compared to the Tiger-compatible solution, I feel it (a little bit) faster by triggering the menu item directly.

However, because of the fact that this needs to call the System Events application, which is Leopard Only, (update: my fault! System Event is NOT Leopard Only, but it is sure that this application is Leopard Only.  See here for more details, and thanks to uranusjr; he also provided a better and faster version of this application) this AppleScript Application is Leopard Only, too.

If you wanna see the source code, just open the goToEnclosingFolder.app with Script Editor.app, or scroll down to the rear of this post to see the pasted code.


[中文版]

就… Windows 檔案總管有上一層的按鈕,可是 Mac OS X 到 10.5 還是沒有 = =

所以自己做ˊˋ

其實已經有現成的可以拿來用了 (這個這個 和 那個),不過它們都是直接 Call Finder 提供的 AppleScript functions。我在想是不是直接 Trigger 那個功能表比較快?

Mac OS X Finder Go to Enclosing Folder TC

所以我研究了一下 教你如何用 AppleScript Trigger 功能表的這篇文章 ,然後做了一個 Leopard Only 的版本:

  1. 抓 → http://dl.getdropbox.com/u/159570/works/goToEnclosingFolder-zh-TW.zip
  2. 然後把 goToEnclosingFolder-zh-tw.app 拉到 Finder 的 Toolbar 上面,就好了。

我是覺得有比 這個適用於 Tiger 的程式 要快一點啦。

缺點就是,因為 System Events 要到  Leopard 才有(修正: 我錯惹! System Event 不是 Leopard 的專利,我只能確定這樣寫的程式只能在 Leopard 上面動。感謝 uranusjr 的指正 ,同時提供了一個更好更快速的程式寫法) 所以這個程式當然也是 Leopard Only。

程式碼的話,直接用「工具指令編輯程式」開這個應用程式就行了,或是你可以看本文下方的貼上版。

至於為甚麼這篇要先寫英文版,科科,想分享給洋鬼子啊不行喔 XD (爆)


Source Code in English:

[sourcecode language=’ruby’]
tell application “System Events”
tell process “Finder”
tell menu bar 1
tell menu bar item “Go”
tell menu “Go”
click menu item “Enclosing Folder”
end tell
end tell
end tell
end tell
end tell

[/sourcecode]

中文版的程式碼:

[sourcecode language=’ruby’]
tell application “System Events”
tell process “Finder”
tell menu bar 1
tell menu bar item “前往”
tell menu “前往”
click menu item “上層檔案夾”
end tell
end tell
end tell
end tell
end tell

[/sourcecode]


p.s.: 亦可參考 uranusjr 所修改的版本,是直接 call shortcut key 的。