Computing.Net > Forums > Disk Operating System > Rename file with date stamp

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 file with date stamp

Reply to Message Icon

Name: jmjsin
Date: January 21, 2003 at 20:04:15 Pacific
OS: WinXP
CPU/Ram: P4, 256mb
Comment:

How do I rename a file to suffix the date.
eg test.txt to text2003-01-21.txt



Sponsored Link
Ads by Google

Response Number 1
Name: datare
Date: January 22, 2003 at 11:27:43 Pacific
Reply:

c:\> ren test.txt text20030121.txt


0

Response Number 2
Name: Secret_Doom
Date: January 29, 2003 at 21:49:43 Pacific
Reply:

I reckon he meant not to hardcode the date. Jmjsin, this should do it:

for /F %%A in ("%DATE%") do ren test.txt test%%C%%A%%B.txt

That will exclude the separators. If you want them, use this instead:

for /F %%A in ("%DATE%") do ren test.txt test%%C-%%A-%%B.txt

Those lines are to be used from inside a batch file. In order to execute them from the command prompt, change the double % signs for single ones (%A instead of %%A and so on).

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br

_________________________________________________________________


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


How to put current WD in ... format compresed hard dis...



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 file with date stamp

Rename file with date www.computing.net/answers/dos/rename-file-with-date/14091.html

Create file with date and time www.computing.net/answers/dos/create-file-with-date-and-time/13843.html

Rename file with current date www.computing.net/answers/dos/rename-file-with-current-date/13069.html