image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
Thread Tools
  #1  
Old April 19th, 2007, 06:03 AM
Registered User
 
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
lpabildgaard is on a distinguished road
Automate process list of PDF downloads

Hello,
I've got a task to download and print 1700 pdf files.
I have extracted the links into a file and now i need to click on each link, print the downloaded pdf, close the window in Safari, return to the list, go to the next link etc, etc.
How do I automate this process? Alternatively I could save the PDF's for later printing.
Reply With Quote
  #2  
Old April 19th, 2007, 01:55 PM
Registered User
 
Join Date: May 2005
Posts: 1,339
Thanks: 0
Thanked 1 Time in 1 Post
barhar is on a distinguished road
Based on 'Alternatively I could save the PDF's for later printing.'.

Partial sample code, to download a list of '.pdf' hypertext links.

-- AppleScript code begins here --

set pdf_URLs to {"http://apps.irs.gov/pub/irs-pdf/i1099h.pdf", "http://apps.irs.gov/pub/irs-pdf/i1099sa.pdf"}

-- Path of 'PDFs' folder (directory) - to be created, and downloaded '.pdf' files saved to (in UNIX format).
set base_Path to ((POSIX path of (path to desktop folder from user domain) as string) & "PDFs/")

try -- Trap 'directory already exists' (or equivalent) error, if folder (directory) already exists.
do shell script ("mkdir " & base_Path) -- If not exists already, create 'PDFs' folder, on current users' 'Desktop'.
end try

repeat with i in pdf_URLs
try -- Trap (and thus ignore) any unforseen 'exception' errors.
set {oAStID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set file_Name to (last text item of i) as string
set AppleScript's text item delimiters to oAStID

do shell script ("curl " & i & " -o \"" & (base_Path & file_Name) & "\"") -- Download, and properly lable, desired '.pdf' files.
end try
end repeat

-- AppleScript code ends here --

I also included (beneath the above code) ...

try
do shell script ("cd " & base_Path & "; lpr *.pdf") -- Print all downloaded '.pdf' files.
end try

... which worked (somewhat). Somehow, the 'HP Utility' (a web page at 'http://npi23061e.local./') deems the print job (of each file) as a 'manual feed'; thus, I must click on a 'Enter' button to actually print, each '.pdf' file.

I may / may not investigate further, at a future time.
Reply With Quote
  #3  
Old April 19th, 2007, 03:22 PM
Registered User
 
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
lpabildgaard is on a distinguished road
thanks :-)!
I'll look at it tomorrow.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 03:56 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.