1
set targetFile to (path to temporary items as string) & fileName

I am trying to download a web image to temporary folder by curl in a Apple Script.

According to the above code, the curl downloads it as correct but the targetFile is currently as:

Macintosh HD:private:var:folders:...TemporaryItems:image.png

But after download, I need the downloaded image path as a correct file path like:

/tmp/image.png

How can I set targetFile as a string that have slash containing file path? Or how can I get the file path of the image after it is downloaded by curl?

1

You can work around this with something like

set a to "/tmp/" & fileName
set targetFile to POSIX path of a
--since you are using curl
do shell script "curl http://example.com/images.jpg > " & targetFile

This AppleScript will make a string containing /tmp/, and targetFile sets it to interpret as POSIX (used by shell and curl). Then it downloads images.jpeg and stores it as fileName

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .