Computing.Net > Forums > Windows XP > Rename log file with date appended

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Rename log file with date appended

Reply to Message Icon

Name: Carl Brown
Date: September 18, 2005 at 17:08:04 Pacific
OS: Windows XP Home
CPU/Ram: 2.4/1G
Comment:

Hi, I wish to rename a log file by appending the date to the end of the file name.

This is what it is named now: log.txt

This is what I want to rename it to using today's date of 09/18/2005: log09182005.txt

After searching this forum I found a previous poster had gotten a reply how to do this in Windows 2K. I tried the suggested command for Windows 2K in my Windows XP Home:

ren log.txt log_%date:~4,2%-%date:~7,2%-%date:~12,2%.txt

and got an error "The syntax of the command is incorrect".

Might anyone know the correct format of this command for Windows XP ?

Appreciate your help !

Carl




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 18, 2005 at 19:20:57 Pacific
Reply:

Hi Carl,

Ut's not so much a w2k/xp issue as it is about the way your DATE is formatted.

Mine is:

Mon 19-09-2005

So I can:

echo %date:~10,4%%date:~7,2%%date:~4,2%

and get:

20050919


If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: Carl Brown
Date: September 19, 2005 at 03:15:44 Pacific
Reply:

Hi M2,

Thanks !! Say that worked just fine !!

For the sake of completeness if anyone else ever reads this thread, the proper DOS command to rename:

before: C:/mysqlback/log.txt

after: C:/mysqlback/log09192005.txt

is the DOS command:

ren c:\mysqlback\log.txt log%date:~10,4%%date:~7,2%%date:~4,2%.txt

Please note that ren wants the full path.

Thanks again M2 !!

Carl


0

Response Number 3
Name: Mechanix2Go
Date: September 19, 2005 at 03:26:36 Pacific
Reply:

Hi Carl,

Yeah, well, you either need to specify the file location or you need to change to the drictory where the file is.

cd c:\mysqlback


If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: Carl Brown
Date: September 19, 2005 at 03:28:44 Pacific
Reply:

For the sake of completeness if anyone else ever reads this thread, the proper DOS command to rename:

before: C:/mysqlback/log.txt

after: C:/mysqlback/log09192005.txt

is the DOS command:

ren c:\mysqlback\log.txt log%date:~4,2%%date:~7,2%%date:~10,4%.txt

You can change the order of the date around easily enough to suit yourself.

Thanks again M2 !!

Carl


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Image placeholders Error messages



Post Locked

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


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Rename log file with date appended

How to rename a file with date/time www.computing.net/answers/windows-xp/how-to-rename-a-file-with-datetime/105340.html

Renaming a file with a datestamp www.computing.net/answers/windows-xp/renaming-a-file-with-a-datestamp/127258.html

rename file with folder name www.computing.net/answers/windows-xp/rename-file-with-folder-name/114886.html