Here's one that is based on the first proposal but will work if:
o there is a directory called c:\windows\temp;
o there ISN'T a directory as above; or
o there IS a directory as above but it doesn't have any files in it.
If there was no directory named c:\windows\temp it will make one before
exiting the batch program but if there is one of that name, it doesn't make
a new one - just empties it (if there is anything to empty).
The Echo lines with text are inserted just to tell you what is going on. The
Echo lines with only a period are just for spacing of the messages. "REM"
prefixed lines are not acted upon at all but are just notes in the batch
file.
Anyway, here is the batch completed batch file I made in Notepad and saved
in the c:\windows directory. It could just as easily have been saved in the
root directory. For my own purposes, I named it "CleanTmp.bat"
@echo off
REM **********************************************
REM * Empty all files in the Windows TEMP folder *
REM **********************************************
c:
cd c:\
IF NOT EXIST C:\Windows\TEMP\NUL GoTo MakeOne
IF NOT EXIST C:\Windows\TEMP\*.* GOTO NODEL
ECHO Y|DEL C:\windows\TEMP\*.*>NUL
Echo.
Echo The TEMP directory has been emptied
GoTo END
:NODEL
Echo.
Echo There were no files to delete!
GoTo End
Echo.
:MakeOne
Echo There was no c:\windows\temp folder so I made one!
MD C:\Windows\TEMP
Echo.
:END
^^^^^^^^^^^^ end of batch file - but don't insert THIS line ^^^^^^^^^^^^^^^^
Larry Stewart
email: [log in to unmask]
Ottawa, Canada
----- Original Message -----
From: "Mark Rode" <[log in to unmask]>
Subject: Re: [PCSOFT] Questiion in MS DOS batch file
> We are talking DOS or Win9x right ?...Not NT4 or Win2K command line?
>
> Well then, you could use a IF Then statement ...uh ... something like this
>>>
>
> @ECHO OFF
> c:
> cd c:\
> IF NOT EXIST C:\windows . . . etc, etc
PCSOFT's List Owner's:
Bob Wright<[log in to unmask]>
Drew Dunn<[log in to unmask]>
|