|
Armin's Spot on the Web |
Discussion |
|---|---|
Finder Script - Open Folder in new Terminal
This Script will open a new Terminal window and automatically The CodeCopy and paste this into Script Editor or open in Script Editor. tell application "Finder"
try
set t to target of Finder window 1
on error -- there is no window, use desktop instead
set t to desktop
end try
-- there is no 'is subclass of... :-(
-- you might to to add the 'package' class to the list
if class of t is not in {folder, disk, class of desktop, class of trash} then ¬
set t to container of t
set thePath to (quoted form of POSIX path of (t as alias))
end tell
tell application "Terminal" set w to make new window at the beginning of every window do script "cd " & thePath & "; ls -al" activate end tell I guess the code is pretty easy to read and understand. The Script checks if the selected file is a container (folder, disk, desktop, trash) and if not (it is a file or package) This line really shows the limitations of OOP in AppleScript. All the classes in the list are subclasses of the class I added BTW: is there any way to make the Terminal execute a script in an exisiting window? Note: There seems to be a bug in the way Terminal handles unicode characters. If you have a folder with unicode characters in the name this script will fail. Apple is aware of the bug. PS: the other way, opening a folder from the terminal is simple. In the Terminal simply type |
|
This page was last updated: Tuesday, November 18, 2003 at 12:42:18 PM Copyright 2010 RSVP - Please Reply Mail me @ arminbatmacdotcom |
|