
i recently posted over at the osxhints forums with a script that i hacked together to enable right- clicking on a folder in OS X and choosing “Open in Terminal” from the Automator menu.
Its pretty handy to be able to use the Finder to navigate instead of cd .. etc etc… and then to start a terminal session just where you want to be. Of course it can also added to with another do script statement to reuse an inactive terminal window to do any other script… and i also noticed that if you put a \n into the command string it will do a line break and create a sequence of commands (but it breaks if you hit the hammer button to compile the script - you have to save it without compiling if you want to do this little /n newline trick).
here is the script for reference:
on run {input, parameters}
repeat with i in input
set theWin to (quoted form of POSIX path of (i as alias))
end repeat
--set myWin to window 1
--set theWin to (quoted form of POSIX path of (target of myWin as alias))
set commandString to "cd " & theWin --& " ls -al"
------------------
tell application "System Events"
if not (exists process "Terminal") then
tell application "Terminal"
activate --start terminal if needed
end tell
end if
repeat while not (exists process "Terminal")
delay 1 --wait for terminal to be ready
end repeat
end tell --Sys Events
----------------
tell application "Terminal" -- Get a free window to run
activate
set windowCount to (count of the windows)
if windowCount is greater than 0 then
repeat with w from 1 to windowCount
if window 1 is busy then
set frontmost of window 1 to false
else
do script commandString in window 1
set frontmost of window 1 to true
return
end if
end repeat
end if
tell window 1
do script commandString
set frontmost to true
end tell
end tell
end run
note:the formatting looks nicer on the forum
101 Cookbooks - http://www.101cookbooks.com/index.rdf
About Today - http://z.about.com/6/nl/rss/todaysl.xml
Adobe Labs - http://weblogs.macromedia.com/labs/atom.xml
Adobe Labs - http://weblogs.macromedia.com/labs/index.rdf
BBC News | Science/Nature | UK Edition - http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/sci/tech/rss.xml
BusinessWeek Online — - http://www.businessweek.com/rss/bwdaily.rss
Cecilie’s World - http://www.herrem.com/?feed=rss2
CNN.com Recently Published/Updated - http://rss.cnn.com/rss/cnn_latest.rss
Dictionary.com Word of the Day - http://dictionary.reference.com/wordoftheday/wotd.rss
Discovery News - http://dsc.discovery.com/news/topstories.xml
dyhr.com - http://dyhr.com/feed/
EarthTrends blogs - http://earthtrends.wri.org/updates/index.php?q=blog/feed
Engadget - http://www.engadget.com/rss.xml
Fodor’s Travel Wire - http://www.fodors.com/blog/index.rdf
Fool.com: The Motley Fool - http://www.fool.com/About/headlines/rss_headlines.asp
Forbes.com: Most popular stories - http://www.forbes.com/feeds/popstories.xml
Funny Quote of the Day - http://www.brainyquote.com/link/quotefu.rss
International Herald Tribune - http://www.iht.com/rss/frontpage.xml
lila.io - http://lila.io/blog/feed/
Nature Materials Update - http://www.nature.com/materials/rss.rdf
News at Nature - Articles published Today - http://www.nature.com/news/rss.rdf
NYT Travel - http://www.nytimes.com/services/xml/rss/nyt/Travel.xml
Official Google Blog - http://googleblog.blogspot.com/atom.xml
Pandora - http://blog.pandora.com/pandora/index.xml
PUBLICATIONS - http://feeds.feedburner.com/WRI_Publications
PureMVC Framework - http://puremvc.org/index.php?option=com_rss&feed=RSS2.0&no_html=1
Quote of the Day - http://www.brainyquote.com/link/quotebr.rss
Reuters: Oddly Enough - http://www.microsite.reuters.com/rss/oddlyEnoughNews
Rotten Tomatoes: Movies - http://i.rottentomatoes.com/syndication/rss/complete_movies.xml
SI.com - http://rss.cnn.com/rss/si_topstories.rss
Welcome to the Land of Possibilities… - http://www.romantic-ideas-for-life.com/Romantic-ideas.xml
Wired Top Stories - http://www.wired.com/news/feeds/rss2/0,2610,,00.xml
I, like _MANY_ other mac users (ex-windows users or not) am baffled that such a full featured OS as OS X could possibly not have the easy ability to merge folders, when you drag one folder into another folder that contains a folder of the same name…
Anyway, just cuz i am baffled, mystified, annoyed etc… my emotions don’t magically create OS updates that solve my problem.
So i got into some applescript. It may not be elegant, but it does something potentially useful to some of you.
It is designed to be used in an Automator workflow in a Run Applescript action box, which is directly connected to a Move to Trash action box. In finder two windows much be open, just as it should be if we were allowed to CONTROL-SHIFT drag the folders over.
There is a confirmation of the destination directory (”window 2″ which is the back window) {beware of the expandable panes and list views, this script takes the target of the window - NOT the selection}
I initiate the script by finding the destination in one finder window, then switching to the source folder and selecting and right clicking (multiple selection is fine) the folders i want to merge into the destination folder. {remember it takes the contents of the source folders}
global the_output
on run {input, parameters}
set the_output to ""
tell application "Finder"
set tgtWin to window 2
set tgtpath to (quoted form of POSIX path of (target of tgtWin as alias))
end tell
display dialog "tgt: " & tgtpath
repeat with i in input
set srcpath to (quoted form of POSIX path of (i as alias))
do shell script "rsync -au --stats " & srcpath & " " & tgtpath & " | grep 'files:'"
set the_output to the the_output & result & "\n"
end repeat
display dialog the_output & " delete src?"
return input
end run

Hmmmmm,
Scientists are one step closer, and once again i ask myself, are we doing things, just because we can? Is quantity / length of life in any way connected to quality of life? And what cost do our technological advances carry?