Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a similar need - How to I rename a fle so the new name contains the date & time of the file. For example, if the file is file.txt with a date of 06/21/2002 and time of 4:00:00 am The new file will be called 06/21/2002 4-00-00am file.txt. I also want to get the server name where the file is stored at the time fo the rename. So the new file name will be something like
Server 06/21/2002 4-00-00am file.txt
Any ideas?
(Windows NT)

Here is a method where you can rename your file to the following format:
server__.txt
The batch job is as follows:
------------
rem Get Current Date
rem Format: DDMMYYYY
rem
rem Get Current Time
rem Format: HHMI
------------
for /f "tokens=2" %%D in ('date /t') do set @DATE=%%D
for /f "tokens=1" %%T in ('time /t') do set @TIME=%%T
set @TODAY=%@DATE:~0,2%%@DATE:~3,2%%@DATE:~6,4%_%@TIME:~0,2%%@TIME:~3,2%------------
------------
rem rename the exported files to include today's date and time
ren test.txt server_%@TODAY%.txt
------------Let us know how you go with it.

![]() |
![]() |
![]() |

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