Audio/video stream recording forums (http://stream-recorder.com/forum/index.php)
-   Audio stream recording (http://stream-recorder.com/forum/forumdisplay.php?f=5)
-   -  

[SOLVED]How to download files with timestamp in filename (Windows).

(http://stream-recorder.com/forum/showthread.php?t=10575)

bat999 12-17-2011 11:53 AM

[SOLVED]How to download files with timestamp in filename (Windows).


 
Hi
With Linux I can use a command like this:-
Code:

NOW=$(date +"%Y-%m-%d-%H-%M"); vlc --run-time=30 http://stream-sd.radioparadise.com:9000/rp_192.ogg --sout "#std{access=file,mux=ogg,dst=$NOW-RadioParadise.ogg}" vlc://quit
It gives me a downloaded file with this filename format:- 2011-12-17-18-36-RadioParadise.ogg

What is the syntax when using Windows from cmd or with a bat script to give the file a name with the timestamp in the filename?

KSV 12-17-2011 12:13 PM

Re: How to download files with timestamp in filename (Windows).


 
http://stream-recorder.com/forum/ren...and-t9041.html

bat999 12-17-2011 02:16 PM

Re: How to download files with timestamp in filename (Windows).


 
This command:-
Code:

for /f "tokens=1-6 delims=/:." %a in ("%date%.%time%") do set FileName="%c-%b-%a-%d-%e-RadioParadise.ogg" && "C:\Program Files\VideoLAN\VLC\vlc.exe" --run-time=30 http://stream-sd.radioparadise.com:9000/rp_192.ogg --sout "#std{access=file,mux=ogg,dst=%FileName%}"
Gives a filename like this:- 2011-12-17-21-02-RadioParadise.ogg
:)

bat999 12-18-2011 06:55 PM

Re: [NOT SOLVED]How to download files with timestamp in filename (Windows).


 
Hi
I think there's a problem when using this method with Windows.
When the hour is a single digit (1am) it is trying to create a filename with a space in it.
Like this:-
2011-12-19- 1-45-RadioParadise.ogg

Maybe something is needed to pad the hour out to 2 digits ("01" instead of " 1").

Perhaps this applies to month and date too.

(With the Linux command it seems to pad out the hour to 2 digits automatically).

KSV 12-18-2011 09:25 PM

Re: [SOLVED]How to download files with timestamp in filename (Windows).


 
actually it's little dependent on your system's time display settings. for example the command
Code:

echo %date%.%time%
outputs
Code:

Mon 19/12/2011. 9:43:13.76
on my system. so i need to work with this string.

the following adjusted command outputs the filename from the above data in the format you want.
Code:

for /f "tokens=2-7 delims=/:., " %a in ("%date%.%time%") do set FileName="MyShow_%a-%b-%c_%d-%e-%f.flv"
Code:

set FileName="MyShow_19-12-2011_9-53-15.flv"

bat999 12-18-2011 10:07 PM

Re: [SOLVED]How to download files with timestamp in filename (Windows).


 
It gives a different result on this Windows XP box.:confused:

Code:

echo %date%.%time%
19/12/2011. 5:01:32.84

Code:

set FileName="MyShow_12-2011-5_02-13-46.flv"
The day (19th) is missing.
I would like a solution that is OK for all Windows systems, whatever the settings.

KSV 12-19-2011 01:04 AM

Re: [SOLVED]How to download files with timestamp in filename (Windows).


 
i have written a little app in c (just 3 lines of code) which will output the current time in fixed format making it easy to parse.
Code:

for /f "tokens=1-7 delims=: " %a in ('timestamp.exe') do set FileName="MyShow_%g-%b-%c_%d-%e-%f.flv"
Code:

set FileName="MyShow_2011-Dec-19_13-29-40.flv"
Code:

http://www.mediafire.com/file/89a7ymiu3s3bsid/timestamp.exe

bat999 12-19-2011 02:55 AM

Re: [SOLVED]How to download files with timestamp in filename (Windows).


 
Yes, timestamp.exe gives an output:-
Code:

C:\Documents and Settings\Administrator\Desktop>timestamp
Mon Dec 19 09:53:15 2011



All times are GMT -6. The time now is 03:25 PM.