Page 1 of 1

Using theFile to send file path to shell script?

PostPosted: Thu Jun 26, 2014 11:12 am
by realdannys
Hi guys,

So basically I'm trying to get imageoptim to run automatically on my screenshots folder when I take one.

At the moment I've got it setup but I need to pass the new file created file name to the program, so I'm working on the embedded script as..

Code: Select all
do shell script "find " & theFile & " | /usr/local/bin/imageoptim -j -q"


Now the problem is, " & theFile & " sends "Macintosh HD:Directory:etc"

No good for a shell script, at the minute it gets stuck because the first space is terminating it, I'd need it sent as "Machintosh\ HD/Directory/etc" Any way I can do that?

Re: Using theFile to send file path to shell script?

PostPosted: Fri Jun 27, 2014 2:48 pm
by Mr_Noodle
You'll need to get the posix path. Check out this page: http://en.wikibooks.org/wiki/AppleScrip ... _and_paths

Re: Using theFile to send file path to shell script?

PostPosted: Fri Jun 27, 2014 5:09 pm
by realdannys
Mr_Noodle wrote:You'll need to get the posix path. Check out this page: http://en.wikibooks.org/wiki/AppleScrip ... _and_paths


:shock: :shock: if only I could understand how to put that into action?!

Re: Using theFile to send file path to shell script?

PostPosted: Mon Jun 30, 2014 10:47 am
by Mr_Noodle
I suggest you read up more on AppleScript. It's probably a bad idea to do scripting blindly.