how to get date in folder name with batch file?

Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

angel

Thread Starter
Joined
Dec 2, 1998
Messages
2,736
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).
 
Joined
Mar 18, 2001
Messages
1,741
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

Thread Starter
Joined
Dec 2, 1998
Messages
2,736
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?
 
Joined
Mar 18, 2001
Messages
1,741
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

Thread Starter
Joined
Dec 2, 1998
Messages
2,736
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?
 

angel

Thread Starter
Joined
Dec 2, 1998
Messages
2,736
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.
 
Joined
Mar 18, 2001
Messages
1,741
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

Thread Starter
Joined
Dec 2, 1998
Messages
2,736
Thanks! I'll grab that and give 'er a try.
Oh, and Mac... you're AWESOME!
 
Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top