Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
I have a quick question about writing a batch file on a winnt4 server.
All it needs to to is to rename a file -easy. But here's the catch. The file must contain a prefix of "sc" an extention of ".log" and the middle part must be the date, in the format yymmdd. For example on the 5th of May this year, the file would look like:
sc010505.log
I am able to do this under other scripting programs, even VMS, but I can't seem to do in with ms-dos. I don't want to have to do a fancy FTP thing or write something in Java or C++.Any thoughts????
tAhDaVnAkNsCiEn
Mark

Place these commands in a batch file and execute. If you are running them outside of a command prompt, change the two %%i variables to %i. Good luck or Glouocdk!
for /f "tokens=2" %%i in ('date /t') do set TEMPVAR=%%iset TEMPDAY=%TEMPVAR:~3,2%
set TEMPMONTH=%TEMPVAR:~0,2%
set TEMPYEAR=%TEMPVAR:~8,2%
echo sc%TEMPYEAR%%TEMPMONTH%%TEMPDAY%.log
ren sc%TEMPYEAR%%TEMPMONTH%%TEMPDAY%.log NEWFILE.TXT

Thanks for that.
is there any on-line help for writing batch files?
I can sort of understand how it works, but I'm still not real sure.

'for /?' or 'help for' is somewhat of a help. 'set /?' is quite good. However, I would recommend 'Windows NT Shell Scripting'. It's a very good book for DOS scripting. NT doesn't have much good infor
And since you mentioned VMS, you've seen XLNT from http://www.advsyscon.com/, right? My boss is quite fond of it. It's a script interpreter for NT/2000 that uses VMS scripting syntax.

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

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