|10 Dec 2011||#1|
Help renaming a .txt file in a .BAT file
I wonder if someone could point me in the right direction?
I have a .BAT file that uses robocopy to backup my data. Part of the robocopy saves the reuslts into a log file called backup_log.txt
At the end of the .BAT file, once robocopy has been completed and the .txt file has been created, I would like to rename it such that the name of the .TXT file references the data and time.
In the CMD window I see I have access to the date /T command, but for the life of me I cannot figure out how to concatenate these commands with the .txt file. Its easy using the Unix move command..........but I'm stumped in CMD.
My goal is to rename backup_log.txt to Sat 10/12/2011_backup_log.txt.
Can anyone make some suggestions?
|My System Specs|
|10 Dec 2011||#2|
Try this batch code -
@echo off set x=_backup_log.txt For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set d1=%%a_%%b-%%c-%%d) set x2=%d1%%x% ren backup_log.txt %x2%
@echo off set x=_backup_log.txt For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set d1=%%a_%%b-%%c-%%d) set x2=%d1%%x% copy backup_log.txt %x2%
Regards. . .
|My System Specs|
|Similar help and support threads for2: Help renaming a .txt file in a .BAT file|
|Batch File Renaming Possible?||Customization|
|Renaming multiple file extensions at once||General Discussion|
|Renaming Files/File Extensions||General Discussion|
|renaming files - file name too large? how to disable this?||General Discussion|
|File and folder renaming/organising help please.||General Discussion|
|Multiple File Renaming||Music, Pictures & Video|
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 10:58 AM.