REM Script to download daily pdfs REM This script is meant for users with active subscription only echo off SET base_url=http://downloads.realviewtechnologies.com/Nation Media/Daily Nation/ SET download_dest=%userprofile%\Downloads\ Rem Don't forget the trailing backslash SET l1=$date = Get-Date -format %%d; SET l2=$month= Get-Date -format MMM; SET l3=$year = Get-Date -format yyyy SET sw1={{($_ -eq '1') -or ($_ -eq '21') -or ($_ -eq '31')}{'st'; break} SET sw2={($_ -eq '2') -or ($_ -eq '22')}{'nd'; break} SET sw3={($_ -eq '3') -or ($_ -eq '23')}{'rd'; break} SET sw4=default{'th'; break}} SET sw_cmd=switch($date)%sw1% %sw2% %sw3% %sw4% set dload_prefix=DN- set cmd1=%l1% %l2% %l3% set cmd2=$date_suff=%sw_cmd% set cmd3=$dest1='%download_dest%%dload_prefix%' set cmd4=$dest2=$month + ' '+ $date + $date_suff + ' ' + $year + '.pdf' set cmd5=$final_dest=$dest1 + $dest2 set cmd6=$source1='%base_url%' set cmd7=$final_source=$source1 + $dest2 powershell -c %cmd1%; %cmd2%; %cmd3%; %cmd4%; %cmd5%; %cmd6%; %cmd7%; write-host 'Downloading to ' $final_dest; Invoke-WebRequest -OutFile $final_dest $final_source rem use this line for older powershell versions (e.g. on Win 7) or if you get error on Invoke-WebRequest rem powershell -c %l1% %l2% %l3%; %cmd2%; %cmd3%; %cmd4% ;%cmd5%; %cmd6% ; %cmd7% ; write-host 'Downloading to ' $final_dest; (New-Object System.Net.WebClient).DownloadFile($final_source, $final_dest) rem ** For BD ** set dload_prefix=BD- set cmd3=$dest1='%download_dest%%dload_prefix%' SET base_url=http://downloads.realviewtechnologies.com/Nation Media/Business Daily/ set cmd6=$source1='%base_url%' powershell -c %cmd1%; %cmd2%; %cmd3%; %cmd4%; %cmd5%; %cmd6%; %cmd7%; write-host 'Downloading to ' $final_dest ; Invoke-WebRequest -OutFile $final_dest $final_source rem use this line for older powershell versions (e.g. on Win 7) or if you get error on Invoke-WebRequest rem powershell -c %l1% %l2% %l3%; %cmd2%; %cmd3%; %cmd4% ;%cmd5%; %cmd6% ; %cmd7% ; write-host 'Downloading to ' $final_dest; (New-Object System.Net.WebClient).DownloadFile($final_source, $final_dest)