By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

Writing a batch file to download many .pdf files...

P: 1
I am attempting to quickly download nearly 1000 .pdf files from a website. Each .pdf has a unique url, and they run in sequence from 1-1000.

I would like help writing a batch file that I could run once and would (in the background) access the .pdf via its url, save a copy, and then move on to the next one.

Similar to (this is sloppy C++ and English combined, its been a while since i've used the language and I do not know Batch files at all):

Expand|Select|Wrap|Line Numbers
  1. int a = 1;
  2. string URL;
  3. for(int i=1; i<1000; i++,a++) {
  4.     URL = ""+a+".pdf"
  5.     open page in background URL;
  6.     save file using existing webpage title name;
  7. }
If it is easier, I also have a text file that includes a list of all the URLs in sequence, so if accessing that file to acquire the text of the URL would be easier, please help me with that instead.

Feb 14 '11 #1
Share this Question
Share on Google+
1 Reply

Guido Geurs
Expert 100+
P: 767
This is how it's done in VB6.
It's also possible to load the textfile with URL's in a list and run trough the list to load and save them.
This example loads the logo of Bytes, saves it on the C:\ and displays it in a picturebox.

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function URLDownloadToFile Lib "urlmon" _
  2.     Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
  3.     ByVal szURL As String, ByVal szFileName As String, _
  4.     ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  6. Private Sub Form_Load()
  7.     ' Download the file.
  8.     URLDownloadToFile 0, _
  9.         "", _
  10.         "C:\logo4.gif", 0, 0
  12.     ' Display the image.
  13.     picBanner.Picture = _
  14.         LoadPicture("C:\logo4.gif")
  16.     ' Size to fit.
  17.     Me.Width = picBanner.Width + 2 * picBanner.Left + _
  18.         (Me.Width - Me.ScaleWidth)
  19.     Me.Height = picBanner.Height + 2 * picBanner.Left + _
  20.         (Me.Height - Me.ScaleHeight)
  21. End Sub
Feb 15 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.