Page 1 of 1

[SOLVED] ~ Batch To Play Radio Stream At Specified Time ~

Posted: 05 Sep 2012 17:36
by Dos_Probie
Ok, Working on my next project, with football season starting up I want record from batch some of my favorite radio station streams
of the pregame and/or postgame shows (approx 1 hr.) at specific day and time to run automatically while I am away.
I can do it manually now from my included test batch file via VLC player that downloads the stream to specified location and
then converts to m4a format etc. but again would prefer to have it run unattended. I found this link: http://forum.videolan.org/viewtopic.php?f=14&t=102156
with a sample batch (but can not get this to work.) And this one: http://dfellows.zzl.org/site_html/batch_files.html (which requires a lot of aux exe files)
Any help would be appreciated..Thanks, Dos_Probie

P.S. The md works first time but after that I get the "already exists" error would like to look
for folder and if found go there and if not make the directory. Thanks again.. :mrgreen:

Code: Select all

@echo off&color a
title [ VLC - RECORDING RADIO STEAM ]
::W7x64

:: VARIABLES
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%date:~4,2%.%date:~7,2%.%date:~10,4%_%date:~0,3%)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a.%%b)
set target=cd "%userprofile%\Recordings\Streams\Radio"&cd>nul
set vlc="%ProgramFiles(x86)%\VideoLAN\VLC\vlc.exe"
set runtime=--run-time=10
set stream=http://provisioning.streamtheworld.com/asx/WJZAMDIALUP.asx
set data=--sout="#transcode{acodec=mp3,ab=128,channels=2,samplerate=48000}:std{access=file,mux=raw,dst='%mydate%_%mytime%_ESPN.m4a'}" vlc://quit

:: MAKE DIR(get already exists error msg)
::md %target%>nul

:: DESTINATION
%target%

:: START TIME
@for /f "tokens=1,2" %%a in ('time /t') do @set time3=%%a%%b
@echo Stream download began at %time3%.
@echo.
@echo Please Wait..This Screen Will Close When Done!

:: RECORD
%vlc% %runtime% %stream% %data%

cls
:: END TIME
@for /f "tokens=1,2" %%a in ('time /t') do @set time3=%%a%%b
@echo.
@echo The Stream Download finished at %time3%.
@echo.
echo Press [ANY KEY] to EXIT.
pause >nul

exit


Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 05 Sep 2012 23:33
by foxidrive
Use this to suppress the error message, when target contains a folder.

Code: Select all

md "%target%" 2>nul



Have you considered using task scheduler?

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 06 Sep 2012 10:47
by Dos_Probie
Thanks Foxi, forgot about the 2nul when already having directory but then I got the "The System cannot find the path specified" and then No directory and subfolders get created..Then I remembered the nul with the If not exist with full path that checks for directory existence and that worked!
P.S I did look at doing task scheduler but now thinking of doing a menu so I can input start/stop or duration times and about half dozen statons to choose from to record then launch from there. :mrgreen:

Code: Select all

if not exist %userprofile%\Recordings\Streams\Radio\nul md %userprofile%\Recordings\Streams\Radio

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 06 Sep 2012 11:13
by foxidrive
Dos_Probie wrote:Thanks Foxi, forgot about the 2nul when already having directory but then I got the "The System cannot find the path specified" and then No directory and subfolders get created..


I'm not surprised!

You set target to be much more than a folder:
set target=cd "%userprofile%\Recordings\Streams\Radio"&cd>nul

and then you tried to MD %target%

That's not the right syntax...

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 08 Sep 2012 14:50
by Dos_Probie
Ok, Tried using the AT command but MS disabled it on Vista and W7, go figure.. :| So then I found out that instead of using the Task Scheduler gui you can just run from command line with schtasks and switches and now all is Working, hope this is of some help to the next person that needs to run a batch at specific date and time. credit: http://ss64.com/nt/schtasks.html


Code: Select all

@echo off&color a
title [SCHEDULE BATCH FILE TASK]

:: Schtasks from Commandline
schtasks /create /tn "Stream.Recorder" /tr "\"c:\espn\ESPN.VLC.cmd\" arguments" /sc daily /sd 09/08/2012 /st 16:30

echo Press [ANY KEY] to EXIT.
pause >nul

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 08 Sep 2012 20:32
by foxidrive
Dos_Probie wrote:Ok, Tried using the AT command but MS disabled it on Vista and W7, go figure.. :|


Do you have a reference for that? AT.EXE still runs in Windows 7, here.

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 09 Sep 2012 11:28
by Dos_Probie
AT.EXE still runs in Windows 7, here.


Foxi, try this command with W7 and tell me what you get.

Code: Select all

AT 14:32 /interactive %comspec% /k 

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 09 Sep 2012 21:48
by foxidrive
AT ran. It's not disabled.

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 09 Sep 2012 22:45
by Dos_Probie
Hmmmm.. Really??
Never said it would not Run but did it complete?
Under XP = COMPLETES Under Current User - "Added a new job with job ID = 1"
Under W7 = LOCKED under Current user - "Warning: Due to security enhancements, blah blah blah .. Acess is denied"

Disable or Locked ... Apples and Oranges. 8)

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 09 Sep 2012 22:53
by foxidrive
Disabled means it doesn't run. Your first language is probably not English.

Anyway, you have schtasks.

Re: ~ Batch To Play Radio Stream At Specified Time ~

Posted: 09 Sep 2012 23:16
by Dos_Probie
[quote:: Schtasks from Commandline
schtasks /create /tn "Stream.Recorder" /tr "\"c:\espn\ESPN.VLC.cmd\" arguments" /sc daily /sd 09/08/2012 /st 16:30

][/quote]

Again Apples and Oranges..

If you Had read my English code I Am using Schtasks and Not AT
So long and short is Microsoft still includes AT.exe (Old carry over from XP) but now has been replaced with Schtasks and recommends using that now.

Schtasks = "SUCCESS: The Scheduled task Stream.Recorder has Successfully been created." :mrgreen: