[comp.os.msdos.programmer] Passing path as Batch parameter

rfh3273@galileo.rtn.ca.boeing.com (Dick Harrigill) (05/04/91)

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