How to pass file path to AppleScript in Automator? -
i want able right click on file or folder in finder , select services > open terminal open terminal window @ path.
in automator, have service runs applescript
tell application "terminal" script "cd $filepath" activate end tell i don't know how pass file path!
bonus: how can ensure works both files , folders? if file, may file not directory.
bonus: have found answer myself? documentation seems way dense.
thanks
chet
note "service receives selected ... " @ top, gives result applescript. open folders , containers of files, won't redundant. 
on run {input, parameters} set didthese {} repeat f in input set f (f text) if f ends ":" if f in didthese --check see if did --ignore else tell application "terminal" script "cd " & quoted form of posix path of f set didthese (didthese & f) --load memory subsequent iterations of loop end if else --first containing folder, use tell application "finder" set f ((container of alias f) alias text) if f in didthese --ignore else tell application "terminal" script "cd " & quoted form of posix path of f set didthese (didthese & f) end if end if end repeat activate application "terminal" end run [edit:] incidentally, 1 thing left decide how treat bundles, .app files, aren't files. using
set info (alias f) then
package folder of will enable script determine this, through additional if/then branch. don't mind "cd"ing bundles.
Comments
Post a Comment