How can a batch file test existence of a directory?
Date: 8 Feb 2002 19:54:04 -0400 The standard way, which in fact is documented in the DOS manual, is: if exist d:\path\nul goto found Unfortunately, this is not entirely reliable. I found it failed in Pathworks (a/k/a PCSA, DEC’s network that connects PCs and VAXes), or on a MARS box that uses an OEM version of MS-DOS 5.0. Readers have reported that it gave the wrong answer on Novell networks, on DR-DOS, and in a DOS window under OS/2. By “failed” I mean that it “found” a directory that didn’t exist, or failed to find one that did exist, or both. (It has been reported that IBM fixed the OS/2 bug in version 2.11 of OS/2.) As a legacy from earlier versions of DOS it always succeeds if the path is DEV. There appears to be no foolproof way to use pure batch commands to test for existence of a directory. The real solution is to write a program, which returns a value that your batch program can then test with an “if errorlevel”. Reader Duncan Murdoch kindly posted the following Turbo Pascal v