Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Rename Filename w/ Date

Original Message
Name: Mugenlude
Date: March 24, 2006 at 09:46:39 Pacific
Subject: Rename Filename w/ Date
OS: XP
CPU/Ram: 3.0/512
Comment:
I have a backup batch file which creates a .log file with starttime, endtime, files backuped, etc.

I combine all of that information into a file called transport.log, I want to rename that file with the current date such as 2006-03-24.log, or better yet 2006-3-24 backuo.log

I'm fairly new to DOS batch files, and DOS commands in general, any help would be appreciated.

-Jason


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: March 24, 2006 at 10:50:15 Pacific
Subject: Rename Filename w/ Date
Reply: (edit)
ren transport.log %DATE%.log


More power, Mr. Scott!

M2Go



Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: March 24, 2006 at 11:18:33 Pacific
Subject: Rename Filename w/ Date
Reply: (edit)
That will work in XP CMD, not DOS.

UNLESS your date layout contains illegal chars.

To find out, do this:

echo %DATE%


More power, Mr. Scott!

M2Go



Report Offensive Follow Up For Removal

Response Number 3
Name: Mugenlude
Date: March 24, 2006 at 11:29:42 Pacific
Subject: Rename Filename w/ Date
Reply: (edit)
"The syntax of the command is incorrect."

I think it is do to the "/" in the date... it displays the date as 3/24/2006.


Report Offensive Follow Up For Removal

Response Number 4
Name: franki
Date: March 24, 2006 at 11:46:13 Pacific
Subject: Rename Filename w/ Date
Reply: (edit)
These two pages are applicable to XP but not MS-DOS as they diferent O/Ses:

http://www.ss64.com/ntsyntax/index.html
http://www.ss64.com/nt/


Report Offensive Follow Up For Removal

Response Number 5
Name: Mugenlude
Date: March 24, 2006 at 12:18:42 Pacific
Subject: Rename Filename w/ Date
Reply: (edit)
I got it figured out... here is what I ended up using.

______________________________

for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=1" %%u in ('time /t') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
set timestr=%d:~6,4%-%d:~0,2%-%d:~3,2%

ren transport.log backup_%timestr%.log
______________________________



Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Rename Filename w/ Date

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Unable to RDP

Windows Updates

VGA Card in 386 clone - dip-switche

Video/Graphics problem

Ping on DOS 6.22


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC