on ApplicationIsRunning(appName)
tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
return appNameIsRunning
end ApplicationIsRunning
tell application "Finder"
try
set winLoc to target of the front window as text
on error
set winLoc to home as text
end try
set pth to quoted form of POSIX path of winLoc
end tell
if ApplicationIsRunning("Terminal") then
tell application "Terminal"
do script "cd " & pth & ""
end tell
else
tell application "Terminal"
activate
set twID to index of front window
end tell
tell application "Terminal"
do script "cd " & pth & "" in window twID
end tell
end if
tell application "Terminal" to activate
do script "mc \"" & pth & "\" \"" & pth & "\""
and the second to:
do script "mc \"" & pth & "\" \"" & pth & "\"" in window twID
In that case the script opens the Midnight Commander with the folder active in both panels. I found this especially useful when I need to extract just one or few files from a zip archive as Midnight Commander allows you to do that.
[crarko adds: I think we've had simliar hints before; I run this one because the Midnight Commander part may be a new wrinkle on it. There was a time when I used to use MC quite a bit, too. I compiled the script to make sure all the quotes matched, let me know if there are any errors with the commands. Script corrected per author's request -- CRA]

