On 10 Jan 2002, at 19:46, Stephen Lo wrote:
> I use the following lines in a batch file to delete all files in a
> folder:
>
> @echo off
> Echo Y| del c:\temp\*.* > Nul
>
> IF folder 'temp' is empty a line "file not found" returns. How
> could I eliminate this feedback?
>
> THank you!!
>
> SLo
I can think of three approaches to try:
1. The single ">" redirects "standard output", but not error
messages. On some Windows versions (I'm most familiar with NT/2000
these days), this can also be written "1>", and there is another
operator "2>" that redirects errors.
2. It should be possible to use the "if exist" command to determine
whether the folder is empty or not. I'm not sure of the exact syntax
-- you don't want the existence of the "." and ".." entries to count.
3. Instead of redirecting the output to Nul, redirect it to
c:\temp\foo. So the batch file doesn't leave the folder empty, it
leaves it with one very small file -- which prevents the error
message from appearing the next time you run the batch. (This might,
however, produce another error message, in which case try one of the
first two, or use "echo" on a third line to recreate c:\temp\foo.
Dave Gillett
PCSOFT's List Owner's:
Bob Wright<[log in to unmask]>
Drew Dunn<[log in to unmask]>
|