Hai All,
How to add date to the file at DOS(CMD line).
I would like to use for AutoBackUps on date wise.

Regards

Recommended Answers

All 5 Replies

Are you trying to use / or . or \ . You can't use these in dos or windows as part of a file name.

Use something like Backup060405.

Hope I actually understood your problem there.

I wrote a program to do that a few years back. It would create a filename using the current date. It was easy to set the parameters of the backup to whatever files I wanted to save in the backup. I will try to find it and make it available.

I do remember looking for a program to do it and did not have much luck.
It also turned out to be harder to write than I expected... About 8 pages...

I'll check around for it.

Sorry, I just re-read your post, you want to run your DOS backup on specific dates not include the date in the filename...

Do you want this to be a TSR terminate and stay resident?
or
Are you planing to put this into the autoexec.bat and check the date on boot?

I see what you meant, sorry.

Hi,
With ref to http://www.cervistech.com/index.php?...id=53&Itemid=2
I would like share how I generated a file with date as filename.
In my environment (it varies according to your environment), my date command output is mm/dd/yyyy
eg: 11/01/2011

So to generate a filename with yyyy-mm-dd, I used following command

echo > %date:~6,4%-%date:~0,2%-%date:~3,2%.txt

So the output is 2011-11-01.txt

to elaborate %date:~6,4% --> From left, the cursor is moved six characters right and displayed only next four characters.

Another method is to change the date format of the system from Regional and Language options. i.e Change the date separator from "/" to "-" and required date format.

~~SAJU~~

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.