Solved

Download Images from URL list with Automator

Posted on 2010-09-09
6
2,053 Views
Last Modified: 2013-11-12
Hi,

I've followed various tutorials that in some cases seem to get quite close, but never close enough:

I have a list of URL's that represent images that - if I wish - I can view and download via my browser.

The only prob is that the list I have is about 1000 rows:  Automator can follow and download one at a time it seems, except that when I paste in 2+ to Get Specified Text it fails.

My feeling is that this is to do with the way that rows are delimited by Automator at the text to URL conversion stage.

I have tried csv, tab-delimited and copying out of excel:  no joy:  can anybody think of why this is stumbling over?

Many thanks in advance.

0
Comment
Question by:jeaniem
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:MBobrek
ID: 33643306
It seems as though Automator is treating your 2+ in there without a HARD return meaning that it's one single line.  Is there any indication that you can force a hard return, or in a preferences area set each line to include a hard return?  

One program I use when I run in a windows environment is FlashGet.  http://www.flashget.com
I haven't had any problems at all downloading various file types with this app.  
0
 
LVL 12

Accepted Solution

by:
nxnw earned 125 total points
ID: 33668198
Never used automator, but several applications are available that should do the job. Bulkloader comes to mind.

Alternatively, paste the attached code snippet into applescript editor and save as an application.

You drop a text file, containing a series of URLs (one per line, i.e separated by hard returns) on the application. It creates a date stamped folder in your downloads folder and downloads each file listed to that new folder.

If there is a dead or mistyped URL, it just skips it without warning, however.  You can code in something to provide a warning in the "on error" clause.


on open thefile
	
	tell application "Finder"
		activate
		set thefile to POSIX path of thefile
		open for access thefile
		set thelist to (read thefile)
		close access thefile
		set foldername to (the month of (current date) as string) & (the day of (current date) as string) & "-" & (do shell script "date '+%H_%M_%S'")
		set folderpath to path to downloads folder as string
		make new folder at folderpath with properties {name:foldername}
		set folderpath to folderpath & foldername & ":"
	end tell
	
	set oldDelimiter to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {"/"}
	
	tell application "URL Access Scripting"
		activate
		repeat with x from 1 to the number of paragraphs in thelist
			set theURL to paragraph x of thelist
			set newFile to folderpath & (the last text item of theURL)
			try
				with timeout of 120 seconds
					download theURL to file newFile
				end timeout
			on error
				set AppleScript's text item delimiters to oldDelimiter
				quit
			end try
			delay 1
		end repeat
		set AppleScript's text item delimiters to oldDelimiter
		quit
	end tell

Open in new window

0
 

Author Comment

by:jeaniem
ID: 33671518
It's working!

Thank you very much indeed - I might note that the files that come down need to be renamed with .png in order to produce an image:  they're not very pretty with .txt written after!

I can't believe how hard it's been to find a solution for this on mac if you're no whiz at scripting or other:  it's possible that the line wraps had something to do with this however.

Many thanks indeed.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Closing Comment

by:jeaniem
ID: 33671524
Thank you very much indeed!
0
 
LVL 12

Expert Comment

by:nxnw
ID: 33671603
The line "set newFile to folderpath & (the last text item of theURL)" just uses the original name of the file as the downloaded file name. I don't know why it would end up being named with a txt extension, unless it already has one.

In any event, if you change that line to:

set newFile to folderpath & (the last text item of theURL) & ".png"

it will tack the png extension to the end of each file name.
0
 

Author Comment

by:jeaniem
ID: 33671624
Great!

Thank you very much again - massive help!

AF
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Syslogd is a utility that traps and logs messages sent by running processes. It is configured with the syslog.conf file, which consists of lines containing a pair of fields: "the selector field which specifies the types of messages and priorities to…
Information security is a multi-billion dollar industry. Just as lucrative is the black market industry which trades stolen identities, credit card numbers and software exploits all over the world. Nothing is hack-proof. The best one can do is make …
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now