Batch Downloads

Hello MacScripter,

Basically I want to batch downloads files from the net.
What I want to do is download urls that are contained in a text file
where each line represents one url for download.

This is very similar to this applescript found at
http://www.strout.net/info/coding/applescript/batch-download.txt
But
It was written for Netscape Navigator 2.0 and I don’t have
Netscape. Tried downloading but froze my comp when installing:)

So, is there someone here that can help me script this for Safri or Firefox
or something that will download these files contained in text file.

What I need from script in above url is

– process one file of URLs
– we need to get the filename from the end of the URL
– download one URL, and save in a folder as the filename taken from previous action
– repeat till all urls downlloaded

Does this work for you? [Edited]

choose folder with prompt "Save downloaded files to this folder:"
set outputFolder to result

display dialog "Enter URL of text file to parse:" default answer (return) buttons {"Cancel", "Choose Local File.", "Download"}
set {text returned:textFileURL, button returned:result} to result

if button returned of result is "Choose Local File." then
	choose file with prompt "Choose local text file to parse:" without invisibles
	set textFileURL to "file://" & POSIX path of result
end if

try
	do shell script "/usr/bin/curl --silent --fail --show-error " & quoted form of textFileURL
	set downloadList to paragraphs of result
	
	repeat with thisItem in downloadList
		try
			do shell script "cd " & quoted form of POSIX path of outputFolder & "; /usr/bin/curl --silent --fail --show-error --remote-name " & quoted form of thisItem
		on error errMsg number errNum
			display dialog "Error " & errNum & return & return & errMsg buttons {"Cancel", "Skip File"} default button 2
		end try
	end repeat
	
	display dialog "Files downloaded successfully!" buttons {"View Download Folder", "OK"} default button 2
	
	if button returned of result is "View Download Folder" then tell application "Finder" to activate (open outputFolder)
on error errMsg number errNum
	if errNum is -128 then error number -128 -- in case we canceled inside the repeat loop
	display dialog "Error " & errNum & return & return & errMsg buttons {"Cancel"} default button 1
end try

Yes, this does work but only for text files hosted on the net.

Most text files I want to parse are located on my computer hard drive.

to make Bruces’ script work with local text files you can use this modification:

choose folder with prompt "Save downloaded files to this folder:"
set outputFolder to result

set tf to quoted form of (POSIX path of (choose file with prompt "Choose text file"))

try
	set URLsText to (do shell script "cat " & tf)
	set downloadList to paragraphs of URLsText
	
	repeat with thisItem in downloadList
	...

Sorry, that’s how I read it last night. You could still use a file URL though; See the edited script above.