1.

Solve : need help with date and filename?

Answer»

hi Friends,
I have a batch script in which I need to automatically save a backup file everday.I need the name of the file should be the current date i.e 09-09-05.txt format.Can SOMEONE please tell me how to accomplish this using DOS commands.
ThanksThere are many ways to do this, depending on your OS and your regional settings, which you failed to MENTION. This may work.

Code: [SELECT]
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (
set mo=%%a
set DA=%%b
set yr=%%c
)

You can use the variables as you wish: %mo%-%da%-%yr%.txt

Hope this helps.



Discussion

No Comment Found