# how to get date in folder name with batch file?



## angel (Dec 2, 1998)

I would like to write a simple batch file for someone that just renames a folder to a name that includes the date it was renamed (ex. rename test to 110801bk). I've found a few references online to getting the system date but nothing that's helped me.
Can anyone show me how to even simply create a folder name that includes the system date? (I could figure it out from there).


----------



## MacFromOK (Mar 19, 2001)

I don't think you can do this without a
batch utility. You can get the date into a
text file by using the following:

echo.|date > test.txt

This basically sends an ENTER key stroke to
the DOS DATE command and routes it to a file,
but it sends the whole text, not just the date
(you can also do this with the TIME command).

It wouldn't really help much to have it in a file.
You need some way to store the date in an env
variable where you can use it from a batch file.

Cheers, Mac


----------



## angel (Dec 2, 1998)

I know I'll need a batch file but not sure how to do it.
So, what you said is exactly what I'm looking for.
no ideas?


----------



## MacFromOK (Mar 19, 2001)

If you want to use a date from a batch
file, you need a utility like PC Magazine's
"batchman" or something similiar.

Does it have to be a date? If you can
just use incremented numbers, you can
probably do it without any other utilities.


----------



## angel (Dec 2, 1998)

I would rather it be the date to be a little more obvious to the person I'm making this for. Yes, they can look at the date on the folder/files but you don't know this person!
I think I'm going to pursue this further but can you tell me how to get numbers in folder names to increment anyway?


----------



## MacFromOK (Mar 19, 2001)

You can check out this post for incrementing
numbers in batch files:

http://forums.techguy.org/showthread.php?threadid=54105

Do you know anything about batch files?
Also, what exactly do you expect the batch
file to do? Is the person going to click on it
or run it from the command line?

Cheers, Mac


----------



## angel (Dec 2, 1998)

I'll check out the other post.
I'm familiar with batch files in that I can write basic ones.
She'll just be clicking on a shortcut on her desktop to execute. It's for a secondary backup of some specigic files. Right now I have it setup so when she runs it it renames the previously made 'backup' to 'backupold' and then makes a new 'backup' so she's always got those two in addition to her server backup.
I'd like for her to have several to choose from and for the name of the folder to include the date.


----------



## MacFromOK (Mar 19, 2001)

I made a small utility to set a variable to the current
date in the format you requested (MMDDYY). If you
(or anyone else) wants it, it's here:

http://www.trinex.net/users/mac/DOS/setdate.zip

You should use it at the beginning of your batch
file as follows (make sure setdate.exe is in in
your path):

*
setdate > setdate1.bat
call setdate1.bat
del setdate1.bat
*
Then you have the variable %DATE% to
work with.

Cheers, Mac


----------



## angel (Dec 2, 1998)

Thanks! I'll grab that and give 'er a try.
Oh, and Mac... you're AWESOME!


----------



## MacFromOK (Mar 19, 2001)

Thanks, let me know how it goes...


----------



## angel (Dec 2, 1998)

Works like a charm!


----------

