Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide 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

19 Dec 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
19 Dec 2010   #2

Windows 7 Pro 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
19 Dec 2010   #3

Windows 8 Core X64
 
 

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





Thread Tools



Similar help and support threads for2: Batch file , change filename with system date and time infor
Thread Forum
Time and Date issue - BIOS time and date reset after change in Win7 General Discussion
Can't change date and time General Discussion
Is there a Script or batch file that can create folders by date range General Discussion
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

Our Sites

Site Links

About Us

Find Us

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

All times are GMT -5. The time now is 01:49 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

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 31 32 33