January 7, 2003 at 1:39 pm
I need to write a script that will rename a file and add the date.
Example: test.txt test010702.txt
Anyone out there know how to do this?
Thanks.
January 7, 2003 at 1:48 pm
hint:
use xp_cmdshell and ren
Build the command string using the datepart functions.
Steve Jones
January 7, 2003 at 3:30 pm
try this using a batch file:
@Echo OFF
cd C:\TempSet TEMPDATE=%TEMP%\TemDate.TMP
DATE /T > %TEMPDATE%
Set PARSEARG="eol=; tokens=1,2,3,4* delims=/, "
For /F %PARSEARG% %%i in (%TEMPDATE%) Do SET YYYYMMDD=%%l%%j%%k
Echo RENAME test.txt Test_%YYYYMMDD%.txt
RENAME test.txt test_%YYYYMMDD%.txt
GoTo END
:USAGE
Echo Usage: DateName filename
Echo Renames filename to filename_YYYYMMDD
GoTo END
:END
erase %TEMPDATE%
Set TEMPDATE=
Set PARSEARG=
Set YYYYMMDD=
January 8, 2003 at 8:10 am
Thanks. I got it working.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply