Solved

Download Images from URL list with Automator

Posted on 2010-09-09
6
2,144 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issues With Outlook for Mac and Exchange? 37 114
Mac Online Backups 7 63
iPhone Mail: manually checking ALL email 3 66
iPhone 6: Testing my battery for failure? 6 74
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…
A common question or need, when setting-up a new Mac for someone would be to make all of the applications, installed, available from the dock. Many people often do not realize an application is installed unless it is in the dock. Creating a custo…
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 …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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