1

Hello I'd like to create a BATch-file to download a mp3 file with a increasing variable parameter URL that change daily. I've tried to use "bitsadmin" command but I've to replace different variables like "year", "month", "day", "series".

Any ideas how to do it?

bitsadmin /transfer grlavoro /download /priority normal http://www.radioarticolo1.com/userdata/media/audio/2015/03/20150331grl1800_54986.mp3 d:\grl.mp3

Is it possibile to do something like this?

@ECHO ON
set series=54986

set /a c=1

FOR /F "tokens=1 usebackq" %%i in (%series%) do (
set /a c=c+1
echo %%i,  %c%
)

for /f "tokens=1-4 delims=/-. " %%i in ('date /t') do (call :set_date %%i %%j %%k %%l)
goto :end_set_date

:set_date
if "%1:~0,1%" gtr "9" shift
for /f "skip=1 tokens=2-4 delims=(-)" %%m in ('echo,^|date') do (set %%m=%1&set %%n=%2&set %%o=%3)
goto :eof

bitsadmin /transfer grlavoro /download /priority normal http://www.radioarticolo1.com/userdata/media/audio/%yy%/%mm%/%yy%%mm%dd%grl1800_%series%.mp3 d:\grl.mp3
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Nik
  • 11
  • 1
  • @SoheilHashemi - that doesn't even remotely address his problem; he's trying to change variables so that he can download all of the episodes of some radio program. – SomethingDark Mar 31 '15 at 22:12
  • Is that code something that you've tried and it isn't doing what you want? – SomethingDark Mar 31 '15 at 22:19
  • take a look at this http://stackoverflow.com/questions/28143160/how-can-i-download-a-file-with-batch-file-without-using-any-external-tools – npocmaka Apr 04 '15 at 09:41

1 Answers1

0

It's easier and less locale-dependent to set your date variables from wmic os get localdatetime.

for /f %%I in ('wmic os get localdatetime /format:list ^| find "="') do set "%%I"
set "YYYYMMDD=%localdatetime:~0,8%"
set "YYYY=%YYYYMMDD:~0,4%"
set "MM=%YYYYMMDD:~4,2%"

Also, it's generally preferable to use the powershell BitsTransfer module rather than bitsadmin, since the latter is deprecated and likely to be removed in future versions of Windows. As a side benefit, you get a nice curses-style progress bar with the powershell command.

set "URL=http://www.radioarticolo1.com/userdata/media/audio/%YY%/%MM%/%YYMMDD%grl1800_%series%.mp3"
powershell "Import-Module BitsTransfer; Start-BitsTransfer %URL% d:\grl.mp3"

I'm afraid I don't understand what it is you're trying to do with your %series% variable. Under what circumstances, and how many times, do you intend to increment it?

I had a look at the website you're leeching. Although I don't understand Italian, I did come across the podcast archive page. All the podcasts offered for download are served by a ColdFusion script accepting an incrementing numeral in the query string. There's no date manipulation needed if you use their audio_download.cfm script. Would it be preferable for you to use that, so you don't have to try to pair the date with a series number? (You're the Italian language expert in this thread. I'm genuinely asking.)

rojo
  • 24,000
  • 5
  • 55
  • 101