Windows 7 Forums Search
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows 7. The Windows 7 forum also covers news and updates and has an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7 - Batch file , change filename with system date and time infor

 
12-19-2010   #1


Windows 7 Ultimate x64
 
 

Batch file , change filename with system date and time infor

I wrote a bat file, to change a file name, test.txt to testMonthDayYearTime.txt



here is what i wrote:
ren c:\example\test.txt test%date:~4,2%%date:~7,2%%date:~10,4%%time:~0,2%%time:~3,2%%time:~6,2%%.txt”



But after running, the file name is test12182010 093012.txt, a space is between date and time. I don;t want the space. Anyone know what's wrong.

My System SpecsSystem Spec
12-19-2010   #2


Windows 7 Ultimate x64 SP1
 
 


i used the same routine to set an environmental variable with your routine and it
worked fine.

set xx= test%date:~4,2%%date:~7,2%%date:~10,4%%time:~0,2%%time:~3,2%%time:~6,2%%.txt

xx= test12192010150311.txt

something tells me that your time display settings could be different than mine.

I love batch files.

Rich
My System SpecsSystem Spec
12-19-2010   #3


 
 


You're missing a double quote. Try this:

ren test.txt "test%date:~4,2%%date:~7,2%%date:~10,4%%time:~0,2%%time:~3,2%%time:~6,2%%.txt"

When I did it from a Command Prompt, I got: test12192010221526.txt

Put it in a batch file and it still works, got: test12192010221739.txt
My System SpecsSystem Spec
.


Reply

 Batch file , change filename with system date and time infor problems?



Thread Tools



Similar Threads for: Batch file , change filename with system date and time infor
Thread Forum
Solved How to create a current date folder using batch file? General Discussion
Change date and time stamp on file save... Performance & Maintenance
batch file to create a daily date folder General Discussion
'Date Modifed' of filename doesn't change General Discussion
Date and Time - Change Tutorials


All times are GMT -5. The time now is 11:19 PM.



Windows 7 Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30