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

Tim Bates timothy.c.bates at gmail.com
Mon Mar 26 13:34:45 UTC 2018


Thank you for your effort and (successful) help!
That was the key: What is returned from the AppleScript is trappable like that!

Best, tim


> On 24 Mar 2018, at 5:36 pm, dipnlik <dipnlik at gmail.com> wrote:
> 
> 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
> 
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20180326/62c7e7c7/attachment.html>


More information about the textmate mailing list