Q: Download pictures from a url and then rename the pictures
Hey guys,
I just discovered the power of Applescript, pretty amazing what you could do with it. I'm learning a lot, but still need your help.
I need an applescript that would download pictures from a url and rename them with a new name. (see picture attached)
I found something like this on Windows, for excel script, but I need something like this for MAC.
Thank you in advance for your time !
null, OS X Yosemite (10.10.5)
Posted on Jul 1, 2016 6:41 AM
Build a text file that looks like the following, where the URL is on a separate line, and the renamed file is on the second line, of each URL couplet. This structure is key to the proper functioning of the AppleScript. I called this file url_list.txt, and put it on my Desktop. Tested on OS X 10.11.5.
-o foo.jpg
-o foobar.jpg
-o bar.jpg
AppleScript
-- Prompt for a text file containing a list of URLs and the output filenames for each URL
-- Process the input list and write files to designated output folder
-- xargs -P2 uses two process threads on the list
-- -n3 there are three items per URL couplet 1) URL, 2) -o and 3) filename
property loc : ((path to desktop) as text)
property outdir : POSIX path of loc & "curlyFiles" as text
property foldername : "curlyFiles"
set url_list to POSIX path of (choose file with prompt "Choose URL list file for cURL")
tell application "Finder"
if not (exists folder outdir) is true then make new folder at loc with properties {name:foldername}
end tell
set status to (do shell script "(cd " & outdir & " && xargs -P2 -n3 <" & url_list's quoted form & " curl -sL)")
if not status is "" then
display alert "Processing of URL list: " & url_list & " has failed." giving up after 10
end if
return
Posted on Jul 1, 2016 2:22 PM

