954,260 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Add date to file Name

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

Regards

bk_raavi
Newbie Poster
10 posts since Oct 2003
Reputation Points: 10
Solved Threads: 0
 

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.

MartyMcFly
Practically a Master Poster
678 posts since Feb 2005
Reputation Points: 16
Solved Threads: 17
 

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?

Thong_Ispector
Practically a Master Poster
638 posts since Nov 2004
Reputation Points: 16
Solved Threads: 19
 

I see what you meant, sorry.

MartyMcFly
Practically a Master Poster
678 posts since Feb 2005
Reputation Points: 16
Solved Threads: 17
 

This is the easiest way i have found. This works natively with Windows and you don't have to download anything or install any scripts.
http://www.cervistech.com/index.php?option=com_content&view=article&id=53&Itemid=2

jntfoster
Newbie Poster
1 post since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

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~~

Saju_C
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You