I have an XML file that has links to various .jpg I want to create an applescript that downloads a local copy of these. The idea is to also label them sequentially with a number say 001 to 030.

Every time i run the script i want the pictures to be overwritten with the new ones.

Here is the XML file I need to use: http://tweetriver.com/hud_ro/steer_filtered.xml?include_entities=1

Can anyone help?

  • Have you actually written any script for us to look at? Is there a language you should be implementing this script in?
    – sofly
    Feb 5, 2013 at 2:23

2 Answers 2


If a shell script solution is acceptable as well, try the following

for u in $(curl -s "$URL" |
           grep jpg | 
           sed -E 's/.*<profile_image_url>(.+)<\/profile_image_url>/\1/'); do
    curl -s "$u" -o $i.jpg
    (( i++ ))

This of course only works for this specific XML example and requires all files to be in jpg format.


Here is another approach:

-- Notice last "/" on path below
set downloadFolder to "/Users/squirrel/Desktop/testFolder/"

set myImages to every paragraph of (do shell script "curl http://tweetriver.com/hud_ro/steer_filtered.xml?include_entities=1 | grep -o \\>.*jpg | sed 's/\\>//'")

repeat with i from 1 to count of myImages
    set fileName to do shell script "echo " & quoted form of (item i of myImages) & " | grep -o [^/]*$ | sed 's/\\.jpg/-" & addOs(i, 3) & ".jpg/'"
    do shell script "curl " & quoted form of (item i of myImages) & " -o " & quoted form of (downloadFolder & fileName as text)
end repeat

on addOs(myNumber, desiredDigits)
    set myNumber to myNumber as text
    set moreOs to desiredDigits - (myNumber's length)
    repeat moreOs times
        set myNumber to "0" & myNumber
    end repeat
    return myNumber
end addOs

You must log in to answer this question.

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