Computing.Net > Forums > Disk Operating System > Rename Filename w/ Date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Rename Filename w/ Date

Reply to Message Icon

Name: Mugenlude
Date: March 24, 2006 at 09:46:39 Pacific
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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 24, 2006 at 10:50:15 Pacific
Reply:

ren transport.log %DATE%.log


More power, Mr. Scott!

M2Go



0

Response Number 2
Name: Mechanix2Go
Date: March 24, 2006 at 11:18:33 Pacific
Reply:

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



0

Response Number 3
Name: Mugenlude
Date: March 24, 2006 at 11:29:42 Pacific
Reply:

"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.


0

Response Number 4
Name: franki
Date: March 24, 2006 at 11:46:13 Pacific
Reply:

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/


0

Response Number 5
Name: Mugenlude
Date: March 24, 2006 at 12:18:42 Pacific
Reply:

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
______________________________



0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Rename Filename w/ Date

Rename file using date www.computing.net/answers/dos/rename-file-using-date/14569.html

Rename file to date.time.txt www.computing.net/answers/dos/rename-file-to-datetimetxt/14166.html

How Do I Rename Files By Date www.computing.net/answers/dos/how-do-i-rename-files-by-date/6312.html