🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.misc
Article #3925

Re: How to know if a dir exists (Batch way)

#3925
From: John Savage
Date: Thu, 14 Dec 1995 00:00
31 lines
2251 bytes
ahmed@cloudburst.seas.ucla.edu (Ahmed A. Jaffer) writes:
>martian (martian@martian.demon.co.uk) wrote:
>>ahmed@cloudburst.seas.ucla.edu "Ahmed A. Jaffer" writes:
>
>> Try     if exist d:\path\nul goto success
>> to test for the existence of d:\path
>
>Unfortunately, this does NOT always work.  The problem involves having some
>(usually network) drivers loaded in memory, which hinder the performance of
>the batch-only-style test (alwyas true/always false). CD-ROM drives can cause
>problems as well, due to their alternate directory layout (i.e. no FAT).  The
>program existdir.exe solves this problem, or, at least, hasn't failed so far!

A further way of determining the existence of a directory can be based
on whether or not there is any output produced by DIR /B

dir /B %1 >tmp1
copy tmp1 tmp2 >\nul
if not exist tmp2 echo DIRECTORY NOT FOUND

This is based on DIR /B producing no output when a directory does not exist.
In practice, the above will need to be preceded by: if exist tmp2 del tmp2
and the temporary files subsequently cleaned up by something like del tmp?

A \full\pathname, if non-existent, causes DIR to write an error message
to CON; so unless tests can be confined to subdirectories only, the DIR
command will need to be bracketed by the CTTY NUL - CTTY CON pair.

I don't know how this method will acquit itself on CD-ROM drives, though.
--
John Savage               koala@sydney.dialix.com.au
Technical Details
Message-ID: <4aou4f$h99$1@sydney.DIALix.oz.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <DIowsq.EsK@seas.ucla.edu> <817947303snz@martian.demon.co.uk> <DJ2ywJ.FJ8@seas.ucla.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d683,d4837396eb3db489,start
X-Google-Attributes: gid10d683,public
X-Google-Thread: 104805,d4837396eb3db489,start
X-Google-Attributes: gid104805,public
X-Google-Thread: f71eb,d4837396eb3db489,start
X-Google-Attributes: gidf71eb,public
From: John Savage <koala@sydney.dialix.com.au>
Subject: Re: How to know if a dir exists (Batch way)
Date: 1995/12/14
Message-ID: <4aou4f$h99$1@sydney.DIALix.oz.au>
X-Deja-AN: 121919098
sender: koala@sydney.DIALix.oz.au
references: <DIowsq.EsK@seas.ucla.edu> <817947303snz@martian.demon.co.uk> <DJ2ywJ.FJ8@seas.ucla.edu>
followup-to: comp.os.msdos.misc,alt.msdos.batch
organization: Gumleaf Smoke Signals Telegraph Co.
newsgroups: comp.os.msdos.misc,alt.msdos.batch,aus.computers.ibm-pc