Re: If exist batch command not working in WinXp
- From: Stan Brown <the_stan_brown@xxxxxxxxxxx>
- Date: Fri, 3 Aug 2007 07:25:53 -0400
Thu, 2 Aug 2007 04:10:00 -0700 from Kitroop
<Kitroop@xxxxxxxxxxxxxxxxxxxxxxxxx>:
"Ken Blake, MVP" wrote:
On Mon, 30 Jul 2007 22:28:00 -0700, Kitroop
<Kitroop@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am trying to use if exist/if not exist in a batch file in Win
XP to test for the presence of files in a directory. However,
it is not working, showing that files exist even if the
directory is empty. Am I dong anything wrong?
Probably. But it's hard to know what without seeing what you're
doing. Post the batch file here.
The batch file is as follows:
~~~~
if exist c:\temp\testing\*.* goto yes
Note -- in XP use "*" for wildcards. "*.*" is okay but sooooo 1980s.
:-)
goto no
:yes
echo file exists
goto end
:no
echo file not exists
goto end
:end
~~~~
The batch file is in the dir C\temp. There are no files under dir
"testing". However the output of the batch file is "file exists".
There are files in c:\temp\testing -- they are called "." and "..".
The only way I can think of to test whether a directory is empty is
to first make your "if exist *" test and then try an RMDIR -- if the
latter fails then the directory was not empty.
There ought to be a better way, and in fact there is in the 4DOS/4NT
shells (which I use). But in native XP I think you have to do it the
hard way.
--
"The Internet is famously powered by the twin engines of
bitterness and contempt." -- Nathan Rabin, /The Onion/
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
.
- Follow-Ups:
- Re: If exist batch command not working in WinXp
- From: Ken Blake, MVP
- Re: If exist batch command not working in WinXp
- Prev by Date: Re: Refine your Ideas in spigit.com
- Next by Date: Xp repair oem
- Previous by thread: Re: If exist batch command not working in WinXp
- Next by thread: Re: If exist batch command not working in WinXp
- Index(es):
Relevant Pages
|