Computing.Net > Forums > Windows NT > File renaming

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.

File renaming

Reply to Message Icon

Name: Keith
Date: June 27, 2002 at 08:21:28 Pacific
Comment:

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)




Sponsored Link
Ads by Google

Response Number 1
Name: Betty Chew
Date: June 30, 2002 at 19:50:55 Pacific
Reply:

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.


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Windows NT Forum Home


Sponsored links

Ads by Google


Results for: File renaming

Rename Files in NT DOS shell www.computing.net/answers/windows-nt/rename-files-in-nt-dos-shell/10917.html

rename files in NT www.computing.net/answers/windows-nt/rename-files-in-nt/21516.html

Files rename using batch file www.computing.net/answers/windows-nt/files-rename-using-batch-file/23142.html