🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #6051

Passing path as Batch parameter

#6051
From: Dick Harrigill
Date: Fri, 03 May 1991 19:42
29 lines
1331 bytes
I have a generic problem with writing batch files.
Can anyone provide a simple solution?

PROBLEM:
  To be able to pass a path/directory to a batch file as a parameter, 
  and be able to act upon a file within that directory.

FOR EXAMPLE:
  1. doit c:
  2. doit a:\mydir
  3. doit c:\mydir\

 where file doit.bat references a file using %1 as the path.

 Within doit.bat:

  %1FILENAME will work with example 1 & 3 but not 2.

  %1\FILENAME will work with example 2 but not 1 (as it will
              incorrectly point to the root) and not 3
              (as you will get a double \).

How do you write a generic batch file that will work with all cases above?

-- 
Dick Harrigill, an independent voice from:     Boeing Commercial Airplanes 
M/S 9R-49  PO BOX 3707                       Renton Avionics/Flight Systems
Seattle, WA  91824                                  Computing Support
(206) 393-9539     rfh3273@galileo.rtn.ca.boeing.com
Technical Details
Message-ID: <374@galileo.rtn.ca.boeing.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!bcstec!galileo!rfh3273

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!bcstec!galileo!rfh3273
From: rfh3273@galileo.rtn.ca.boeing.com (Dick Harrigill)
Newsgroups: comp.os.msdos.programmer
Subject: Passing path as Batch parameter
Message-ID: <374@galileo.rtn.ca.boeing.com>
Date: 3 May 91 19:42:27 GMT
Organization: be30r
Lines: 29