🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.misc
Article #3419

Re: Windows DOS box is lying to me

#3419
From: Peter Hayward
Date: Tue, 13 Dec 1994 11:43
66 lines
3440 bytes
In article <787224072snz@azmi.demon.co.uk>
           azmi@azmi.demon.co.uk "Azmi Tenikalp" writes:

|
|      The DOS batchfile test for the existence of a directory,
|
|           if exist dir_name\nul goto blah_blah_blah
|
|      fails to work properly ONLY on one machine, and ONLY when run
|      in a DOS session within Windows - it reports the existence of
|      the directory, whether this is true or not.
|
   The above method does not work for CD-ROM drives and I suspect certain,
   but not all, networked drives (as you have found).  Hopefully the
   solution is

         if exist dirname\*.* goto .......

   which should work for all directories as they contain '.' and '..' even
   when empty. It works for CD-ROM directories (under DOS) and should work
   over networks, though I haven't (been able to) tested this.  I also don't
   run Windoze unless I'm forced to, so I hven't tested that.  The answer
   comes from PcPlus magazine, help screen, edition 99, Jan 95.

   I have a particular interest in this as I've always wanted to write a CD
   command that (IMO) worked.  I want a unitary file system and I'm not
   normally interested in whether a directory is on C: or D: etc. If I have
   duplicate directory names then I am prepared to live with _known_ search
   rules.  BTW using the DOSKEY program it is possible over-ride/replace
   built in commands like CD with your own commands or a batch file.

   The simplest, _but_ not the most efficient solution I have come up with
   is

   DOSKEY CD=<path.bat> $*

   with <path.bat> containing

   @echo off
   set drive=
   rem N.B. search will find directory nearest the right in this list
   set list=h:,g:,f:,e:,d;,c:
   for %%d in (%list%) do if exist %%d%1\*.* set drive=%%d
   if not '%drive%' == '' goto cd
      echo Directory %1 does exist on drives %list%
      goto exit
   :cd
   %drive%
   cd %1
   :exit
   rem tidy local variables
   set drive=
   set list=

   This could be improved with syntax checking of %1 for a leading '\'
   (could be done with the setenv program) and for efficienvy it would also
   be nice to break out of the for loop and get at the %%d variable, but I
   don't think that can be done.

   Of course it would be far easier and probably more efficient to write a
   tiny 'C' program to do the job but some of us get a perverse sort of
   pleasure from using 'standard' facilities.

--
Peter Hayward, Cambridge, UK                 | Life is symetrical about 42
peter@cdsl.demon.co.uk, tel +44-1223-312-923 | and I'm on the downside.
Technical Details
Message-ID: <787319035snz@cdsl.demon.co.uk>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!pipex!demon!cdsl.demon.co.uk!peter
References: <787141964snz@azmi.demon.co.uk> <787224072snz@azmi.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1036bc,9ff9719c69a20c16
X-Google-Attributes: gid1036bc,public
X-Google-Thread: 1102f1,9ff9719c69a20c16
X-Google-Attributes: gid1102f1,public
X-Google-ArrivalTime: 1994-12-13 06:00:55 PST
Newsgroups: comp.os.ms-windows.misc,demon.tech.pc
From: peter@cdsl.demon.co.uk (Peter Hayward)
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!pipex!demon!cdsl.demon.co.uk!peter
Subject: Re: Windows DOS box is lying to me
References: <787141964snz@azmi.demon.co.uk> <787224072snz@azmi.demon.co.uk>
Organization: Cambridge Digital Systems Ltd
Reply-To: peter@cdsl.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.29
Lines: 44
X-Posting-Host: cdsl.demon.co.uk
Date: Tue, 13 Dec 1994 11:43:55 +0000
Message-ID: <787319035snz@cdsl.demon.co.uk>
Sender: usenet@demon.co.uk