Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!atha!aunro!alberta!mts.ucs.UAlberta.CA!Al_Dunbar From: userAKDU@mts.ucs.UAlberta.CA (Al Dunbar) Newsgroups: comp.os.msdos.misc Subject: Re: Passing path as Batch parameter Message-ID: Date: 9 May 91 04:44:30 GMT References: <375@galileo.rtn.ca.boeing.com> <1991May5.210006.417@sc2a.unige.ch> Organization: MTS Univ of Alberta Lines: 40 In article <1991May5.210006.417@sc2a.unige.ch>, fisher@sc2a.unige.ch writes: >In article <375@galileo.rtn.ca.boeing.com>, rfh3273@galileo.rtn.ca.boeing.com >(Dick Harrigill) writes: >> I have a generic problem with writing batch files. <<>> > > SOLUTION: > Use a little known trick to check the existence of a directory and > a bit of fall-through logic. > <<< deletions: explanation that NUL exists in all directories>>> <<< code fragment follows: >>> > > set _vd= > if exist %1NUL if exist %1\NUL set _vd=%1 > if no%_vd% == no if exist %1\NUL set _vd=%1\ > if no%_vd% == no if exist %1.\NUL set _vd=%1 > if no%_vd% == no goto no_vd A neat trick, but not foolproof. It handles even the oddball "..".."..".."..", but catches you when you try to back up past the root directory. Where it does fail is with a directory name such as ".."""""", which it heralds as an existing directory, even though CD and DIR object. You could go a step further and check for a file such as direxist in the tentative directory. If it exists, the directory must exist; if not, create it and try again. If it then exists the directory must exist; if not the directory either doesn't exist or the disk is full. Oh, well, .BAT files aren't quite DCL! -------------------+------------------------------------------- Al Dunbar | Edmonton, Alberta | Disclaimer: "I disclaim disclaimers" CANADA | -------------------+-------------------------------------------