[TxMt] Re: post-processing results of osascript to insert into document

dipnlik dipnlik at gmail.com
Sat Mar 24 17:36:42 UTC 2018


You're running a bash script, and osascript returns the list, so you
can attribute the script return value to a variable and use it however
you want.  I did this simple test:

#!/usr/bin/env bash
sleep 5
result=$(/usr/bin/osascript -e etc etc etc...)
echo $result

Saved this script, then executed it and quickly cmd tabbed to a finder
window and cmd a.  The script printed the list of selected files to
the terminal as expected.

I'm not a PHP developer but Google says you can use shell_exec() to
run your osascript and save its return to a variable.

Hope that helps.

--
:: dip


On Tue, Mar 13, 2018 at 11:15 AM, Tim Bates <timothy.c.bates at gmail.com> wrote:
> Hi,
> I have a command (copied below) which grabs the paths of the selected items in the Finder, and inserts them into a textmate doc.
>
> I'd like to do some post-processing of the result (replace e.g. replace "/Users/.*/" with "~", and strip trailing return character.
>
> How does one take the resulting string from a script, and process it, say, in php or bash. or should I just work on post-processing theList in applescript?
>
> Thanks!
>
>
> #!/usr/bin/env bash
> osascript -e 'tell application "Finder"
>  set theFiles to selection
>  set theList to ""
>  repeat with f in theFiles
>     set theList to theList & "\"" & POSIX path of (f as alias) & "\","
>  end repeat
>  return theList
> end tell'
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate


More information about the textmate mailing list