Windows – Batch script to run multiple wget commands

scriptingwindows

I'm trying to create a script that has multiple wget commands that include site credentials to download a file. If I run the wget command individually in a command prompt, the file downloads properly.

If I create a batch script to include multiple wget commands, none of the files download properly. I'm not proficient in scripting and haven't found a solution online. Is it possible to run multiple wget commands within a batch file?

This is an example of my batch script.

 q@echo off
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%yyyy%%mm%%dd%


wget -v --http-user="username" --http-password=password "http://server/dira/file:format=PDF" -O "C:\test\%date%file.pdf"

wget -v --http-user="username" --http-password=password "http://server/dirb/file2:format=PDF" -O "C:\test\%date%file.pdf"

Best Answer

If you know the URLs you are wanting to download from you could store the download files or URLs in a text file then use the wget -i option

This question here posted on SuperUser may help out as well