🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.programmer
Article #385

Re: Current directory from batch file

#385
From: lubkt
Date: Thu, 03 May 1990 20:32
55 lines
2680 bytes
In article <90122.175401MCCABE@MTUS5.BITNET>, MCCABE@MTUS5.BITNET 
(Jim McCabe) writes: 

> I'm sure this is a simple question, but I've only recently started writing
> batch programs that had any complexity at all.  I would have avoided it
> if possible, but my job demands it.  :(
> 
> Is there any way to find out what the current directory (and current drive
> for that matter) is from within a batch file?  I am working on a program
> that changes directories all over the place, and it would be very nice
> to be able to place the user back in the original directory before
> terminating. 
> 
> In Unix there is an environment variable that always holds the current
> working directory, but the manual doesn't seem to say anything about it.
> Can anyone help me out at all on this one?  I'd rather keep it all
> within a single program, if possible.  We're using DOS 3.30 here.
> 
> Thanks!
>                                                 Jim McCabe
>                                                 MCCABE @ MTUS5.BITNET

You can use the "apply" command. I know for sure that "apply" is
available on MS-DOS V3.2 and V3.21, but as I recall it is no longer
supported. I might be mistaken, so check it out.

The syntax of "apply" is

  	apply <filename> "command" [/S]

If an  input file, say INPUT.FIL, contains  the text  "C:\DOSDIR", the
following  command will execute  the command equivalent to  typing "cd
c:\dosdir":

	apply input.fil "cd %"

If you are including  the above command in a  batch-file,  you have to
put and extra `%' character, as is shown below for the above command:

 	apply input.fil "cd %%"

You can use the "cd > input.fil" or the "cd d: > input.fil" command to
store the path name in input.fil.

P.S.: If your version does  not have the  "apply" command, try getting
it from somewhere. It is an external command and does not complain too
much about versions.

-Binod.
-------------------
Binod Taterway, User Consultant,                      
Lehigh University Computing Center    BT00@lehigh.BITNET 
Bethlehem, PA 18015                   LUBKT@vax1.cc.lehigh.EDU (Internet)
Disclaimer: I disclaim nothing; I think I ought to be responsible for
whatever I say.
Technical Details
Message-ID: <10153.26405d35@vax1.cc.lehigh.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!rochester!rutgers!netnews.upenn.edu!vax1.cc.lehigh.edu!lubkt
References: <90122.175401MCCABE@MTUS5.BITNET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!rochester!rutgers!netnews.upenn.edu!vax1.cc.lehigh.edu!lubkt
From: lubkt@vax1.cc.lehigh.edu
Newsgroups: comp.sys.ibm.pc.programmer
Subject: Re: Current directory from batch file
Message-ID: <10153.26405d35@vax1.cc.lehigh.edu>
Date: 3 May 90 20:32:53 GMT
References: <90122.175401MCCABE@MTUS5.BITNET>
Organization: Lehigh University
Lines: 55