Computing.Net > Forums > Disk Operating System > MS-DOS Batch question

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.

MS-DOS Batch question

Reply to Message Icon

Name: Mark Legosz
Date: May 7, 2001 at 17:01:33 Pacific
Comment:

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




Sponsored Link
Ads by Google

Response Number 1
Name: John Wolfenbarger
Date: May 7, 2001 at 18:22:15 Pacific
Reply:

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=%%i

set 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


0

Response Number 2
Name: Mark Legosz
Date: May 7, 2001 at 19:24:02 Pacific
Reply:

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.


0

Response Number 3
Name: John Wolfenbarger
Date: May 8, 2001 at 17:26:03 Pacific
Reply:

'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.


0

Response Number 4
Name: Athinarayanan
Date: May 8, 2001 at 23:40:45 Pacific
Reply:

Can I have any solution for this on windows 9x platform?

Thanks
Athi


0

Sponsored Link
Ads by Google
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 Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: MS-DOS Batch question

Ms-dos ftp www.computing.net/answers/dos/msdos-ftp/13009.html

MS-DOS partitioning question. www.computing.net/answers/dos/msdos-partitioning-question/6345.html

Dos/batch password blanking www.computing.net/answers/dos/dosbatch-password-blanking/11332.html