[RESOLVED] Simple batch file problem...

Hi All, :)

I have a very simple problem, I want to create a Batch File for DOS, which rename an existing file by current Date and Time Stamp.

For e.g.
If the current Date/Time is 12th Mar 2007 15:30:00
Old File Name : abc.txt
New File Name : abc__12032007153000

Please help me out... :confused:
[337 byte] By [manu.patel] at [2007-11-20 6:08:55]
# 1 Re: [RESOLVED] Simple batch file problem...
I did something like this a while ago, here's a piece of the batch:

::Parse the time variable into timeStamp
FOR /F "tokens=1-4 delims=/:. " %%J IN ("%time%") DO SET timeStamp=%%J_%%K_%%L

::Parse the dat variable into dateStamp
FOR /F "tokens=2-4 delims=/:. " %%J IN ("%date%") DO SET dateStamp=%%J_%%K_%%L

::Create the file name (will have spaces after each variable value
set filename=Performance_%dateStamp%_%timeStamp%.log

::Parse the filename again and get rid of the spaces
::FOR /F "tokens=1-4" %%J IN ("%filename%") DO SET filename=%%J%%K%%L

Hope that helps :)
Zachm at 2007-11-10 3:39:29 >
# 2 Re: [RESOLVED] Simple batch file problem...
Hi,

Thanks for ur reply, actually i am not able to understand the code, as i want to create a Batch File in DOS for Windows.

Will this code run?
manu.patel at 2007-11-10 3:40:25 >
# 3 Re: [RESOLVED] Simple batch file problem...
Yes, it creates a file named: Performance_%time-stamp%.log
It's pretty close to what you intended to do - slight modifications needed.

It IS a batch file to run under windows.

Best of luck !
Zachm at 2007-11-10 3:41:24 >
# 4 Re: [RESOLVED] Simple batch file problem...
Hi Zachm,

I have tried but its not working. :cry:
I think I should more eleborate the issue: :rolleyes:

I have a file name abc.txt in "D:\Paths" path

Now I want to rename this file as abc_<CurrentDate>_<CurrentTime>.txt thru batch
manu.patel at 2007-11-10 3:42:29 >
# 5 Re: [RESOLVED] Simple batch file problem...
This worked for me under WinXP:

::Parse the time variable into timeStamp
FOR /F "tokens=1-4 delims=/:. " %%J IN ("%time%") DO SET timeStamp=%%J_%%K_%%L

::Parse the dat variable into dateStamp
FOR /F "tokens=2-4 delims=/:. " %%J IN ("%date%") DO SET dateStamp=%%J_%%K_%%L

::Create the file name (will have spaces after each variable value
set filename=abc_%dateStamp%_%timeStamp%.txt

rename D:\paths\abc.txt %filename%

Output file was: abc_03_12_2007_11_22_37.txt
Zachm at 2007-11-10 3:43:27 >
# 6 Re: [RESOLVED] Simple batch file problem...
Thanks a Million, it works... :D
manu.patel at 2007-11-10 3:44:26 >