Solved

Download Images from URL list with Automator

Posted on 2010-09-09
6
2,300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Set up iPhone and iPad email signatures to always send in high-quality HTML with this step-by step guide.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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