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
beidog

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
richnrockville

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
Ztruker

Windows 10 Pro 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
Thread Forum
i want to create a batch file to disable changing system time and date
hi, i want to create a batch file to disable changing system time and date hope some one will sure help me thank you
System Security
Need batch file to disable the date and time option
Hello, I need batch file or registry to disable the date and time option
General Discussion
Batch File for Windows Date and Time - Dual Boot
Morning All, A long time reader and user of advice on the forum but in need of advice if possible. Long story short but for work purposes I have to have a Win 7 dual boot system that I need to log in and change the time to USA regional time on one of my setups. A number of times I have...
Customization
Change date and time stamp on file save...
When I create a file in Windows 7 and save it I get the current date and time stamp but when I edit the program at a later time and date and save again it doesn't change the date and time stamp it stays the same as the original file! I feel like a moron but how can I change this?
Performance & Maintenance
'Date Modifed' of filename doesn't change
I'm working in AutoCAD, saving a VBA project. The VBA changes are saved in the file, but the Date Modified date in Windows Explorer doesn't change! And the Date Modified reported is OLDER than the Date Created. Not good... anybody else notice this behavior? Any way to fix it? thanks in...
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 17:09.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App