cURL image downloading issue

I am trying to download a series of images from a list. The following is an example:

set testing to "http://photocache.petfinder.com/fotos/WA53/WA53.20914066-1-t.jpg"

set AppleScript's text item delimiters to {"-"}
repeat with g from 1 to 3
	set theImage to text item 1 of testing & "-" & g & "-x.jpg"
	---------------------------
	--Just to prove the var theImage is valid
	tell application "Safari"
		open
		activate
		set the URL of tab 1 of window 1 to theImage
	end tell
	---------------------------
	
	-====================-
	--This part doesn't work
	do shell script "curl -f '" & text item 1 of testing & "-" & g & "-x.jpg' -o '/Volumes/SpecialSections/Special Pages O-R/Pet Pages/Process Pics/" & g & ".jpg'"
	--This also doesn't work
	do shell script "curl -f '" & theImage & "' -o '/Volumes/SpecialSections/Special Pages O-R/Pet Pages/Process Pics/" & g & ".jpg'"
	----------------------
--- I am using the single quotes and then double quotes properly in the script command...
	
	
	--This part is an example and it DOES work using the file path of the save to.....
	do shell script "curl -f 'http://www.herpjournal.com/Headers/herpjournal.jpg' -o '/Volumes/SpecialSections/Special Pages O-R/Pet Pages/Process Pics/" & g & ".jpg'"
	
end repeat

Any help sorting this out would be great. I have the save location down, so you can change that.

Hi,

hope I got you right …

set FileDestination to ((choose folder) as text)
set urlList to {"http://cache.kalaydo.de/mmo/2/218/725/52_100332148.jpg", "http://cache.kalaydo.de/mmo/2/218/725/52_-550113444.jpg"}


repeat with i from 1 to count of urlList
	set theUrl to item i of urlList
	
	set fileName to my getFileName(theUrl)
	set targetFile to FileDestination & fileName
	
	try
		do shell script "curl -o " & quoted form of POSIX path of targetFile & " " & quoted form of theUrl
--may place some errorhandling
	end try
	
end repeat
set AppleScript's text item delimiters to ""

on getFileName(theUrl)
	set AppleScript's text item delimiters to "/"
	return (text item -1 of theUrl)
end getFileName

→ hint: have a look at the codeexchange section

Have a nice day

Hans-Gerd Claßen

It turns out I wasn’t doing a whole lot wrong. The image url I was trying to use was redirecting to a new url of the actual image.