1.

Solve : Filename backup with YYMMDD in filename?

Answer»

Hi there, I am trying to create a script to backup a few FILES - I have the backup script written, and it works - but I can't FIGURE out how to put YYMMDD date format into the filename. I've SCOURED Google and I can't find any help. Am I just retarded? Every sript I tried from Google gives me the same thing "MMYYYY". Which isn't what I want, nor what they say should happen.

Any help would be greatly appreciated.

Thanks.Would help to see your existing script and to also know what date you want to put into the file name.
Today's date?
File creation date?
File last modified date?I GUESS if it is a backup then today's date is needed - and this is a FAQ so you should find millions of scripts to deal with today's date.

The first four lines of this code will give you reliable YY DD MM YYYY HH Min Sec variables in XP Pro and higher.

Code: [Select]echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "datestamp=%YY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
echo datestamp: "%datestamp%"
echo timestamp: "%timestamp%"
pause



Discussion

No Comment Found