There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
how to get date in folder name with batch file?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
angel's Avatar
Distinguished Member with 2,824 posts.
 
Join Date: Dec 1998
Location: NE of Madtown, WI
08-Nov-2001, 04:10 PM #1
how to get date in folder name with batch file?
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's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
08-Nov-2001, 04:44 PM #2
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
__________________
MacFromOK : PC User
Do I have all the answers?
I don't even have all the questions!

____________________________________________________________
angel's Avatar
Distinguished Member with 2,824 posts.
 
Join Date: Dec 1998
Location: NE of Madtown, WI
08-Nov-2001, 04:48 PM #3
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's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
08-Nov-2001, 05:01 PM #4
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's Avatar
Distinguished Member with 2,824 posts.
 
Join Date: Dec 1998
Location: NE of Madtown, WI
08-Nov-2001, 05:04 PM #5
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's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
08-Nov-2001, 05:11 PM #6
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
__________________
MacFromOK : PC User
Do I have all the answers?
I don't even have all the questions!

____________________________________________________________
angel's Avatar
Distinguished Member with 2,824 posts.
 
Join Date: Dec 1998
Location: NE of Madtown, WI
08-Nov-2001, 09:35 PM #7
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's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
08-Nov-2001, 11:36 PM #8
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
__________________
MacFromOK : PC User
Do I have all the answers?
I don't even have all the questions!

____________________________________________________________

Last edited by MacFromOK : 02-Jul-2002 06:49 PM.
angel's Avatar
Distinguished Member with 2,824 posts.
 
Join Date: Dec 1998
Location: NE of Madtown, WI
09-Nov-2001, 07:26 AM #9
Thanks! I'll grab that and give 'er a try.
Oh, and Mac... you're AWESOME!
MacFromOK's Avatar
Senior Member with 1,947 posts.
 
Join Date: Mar 2001
Location: Oklahoma
Experience: idiota de la aldea
09-Nov-2001, 12:50 PM #10
Thanks, let me know how it goes...
angel's Avatar
Distinguished Member with 2,824 posts.
 
Join Date: Dec 1998
Location: NE of Madtown, WI
09-Nov-2001, 12:59 PM #11
Works like a charm!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:18 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.