Solved

Download Images from URL list with Automator

Posted on 2010-09-09
6
2,096 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

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…
Create a default user profile for Mac OS X 10.7/10.8 Create a user account on OS X that will be a template for every other user of that computer. I usually call it “profile” and make it an administrator account for the time being. 1. Install a…
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 …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

22 Experts available now in Live!

Get 1:1 Help Now