Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Day stamp to file

Status
Not open for further replies.

Genka28

MIS
Nov 8, 2004
14
0
0
US
Hi, I need help :)))

I need to have a batch script to apend a date stamp to a file, does any one have any ideas. For exampe if I have a file "HELLO" i need to make it "HELLO.MMDDYYHHMM"

any help will be greatly appreciated
 
If you're using UK format date/time, the following will work. Save it as something like rendate.bat

If you're using other date formats, use "echo %date%" and "echo %time%" to work out which variables to change.

The :~0,2 means start at character 0 for 2 characters.
The %-2 means use the last two characters.

--------------------
if "%1"=="" goto :usage
if not exist "%1" goto :notexist
set d=%date:~0,2%
set m=%date:~3,2%
set y=%date:~-2%
set hh=%time:~0,2%
set mm=%time:~3,2%
rename %1 %1.%m%%d%%y%%hh%%mm%
goto :EOF

:usage
echo Usage: %~n0 ^<filename^>
goto :EOF

:notexist
echo %1 does not exist.
goto :EOF
----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top