Using theFile to send file path to shell script?

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..
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?
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?