Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
Is anyone able to tell me if there is a way that I can use a batch file command to rename a directory with the current date and time?I want to be able to execute this batch file so that every time it creates a new folder that is unique to the date and time when it was created, thus not deleting the previous folder.
Any help or guidance to an application that does this would be greatly appreciated.
Regards,
James

It depends a lot on the version of DOS.
And the language, codepage and a few other things.
Post what you get with this:
time
[enter]
[enter]date
[enter]
[enter]
If at first you don't succeed, you're about average.M2

Hi that works fine in terms of displaying the date and time but doesn't give me the ability to use those values as the name of a new directory. I am actually using XP and running from a command prompt. I guess I will need to write a simple application in a programming language. It would have been nice if if was already available though.
Thanks,
James

Since you're using XP, post the outputs of:
echo %time%
echo %date%
If at first you don't succeed, you're about average.M2

Thats exactly the values i want
How can I get these values to become the name of a new directory, is it possible to include these with the rename command of DOS?
Is there another way?
Thanks,
James

Hi James
This Help, the For Loops are on one line.
@echo off
rem Make Directory With Name Date and Time
for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a-%%b-%%cfor /f "tokens=1-2 delims=: " %%a in ('time /t') do set XTime=%%a.%%b
echo %XDate% %XTime%
md "%Xdate% %XTime%"

Hi dtech10,
Yer
I asked twice for the date layout and never got it.
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |