Article View: comp.sys.ibm.pc.programmer
Article #407Re: Current directory from batch file
From: Andy Sun Anu-guest
Date: Mon, 07 May 1990 11:21
Date: Mon, 07 May 1990 11:21
68 lines
2720 bytes
2720 bytes
In article <1873@gannet.cl.cam.ac.uk> cca10@cl.cam.ac.uk (Christopher Anderton) writes:
>The solution I use for this is as follows ...
>
>PATH >c:\savepath.bat
>...
>... code here
>...
>call c:\savepath
>del c:\savepath.bat
>
>I use DOS V4.00 on PS2/50Zs.
>
>Chris Anderton
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>Chris Anderton :: CCA10@UK.AC.CAM.PHX "Meaningless, Meaningless", said the
> :: CCA10@UK.AC.CAM.CL Teacher. "Utterly Meaningless! Everything
>The above are JANET addresses. is Meaningless."
I thought the above will only reset the path, but will not bring you
back to the right directory, regardless of your hardware and software.
I thought what the original poster asked was:
(1) say, you are in C:\DIR1
(2) you execute a batch file which have a lot of CDs so that at the end
of the batch file, you end up in, say, C:\DIR2\DIR3\DIR4.
(3) upon terminate of the batch file, you need to go back to C:\DIR1
automatically.
I don't think what you said above can accomplish this task.
I couldn't think of any combination of genuine DOS commands that can
accomplish that task. However, if you have one of those public domain
PC U*IX "pwd" and "sed" programs handy, then you can do something similar
to the above, like:
pwd | sed -s 's/^/cd /' > c:\savedir.bat
...
... code here
...
c:\savedir.bat
del c:\savedir.bat
I don't like this either because it's like I am talking about a different
operating system (someone might say, if you use pwd and sed, why not
use pushd and popd...).
If the original poster doesn't mind a bit of programming, a few (< 10) lines
of C code can get the current directory and construct and echo the string
"CD <current path and directory>". Say, if you call it SHOWDIR.COM, in
your batch file, you can simply do
showdir > c:\savedir.bat
...
... code here
...
c:\savedir.bat
del c:\savedir.bat
If you will change to directories in a different drive, then the above
won't work either. You'll have to grab and display the drive name in your
program also, something like:
<drive name>:
CD <current path and directory>
Hope this helps and sorry for this long message.
Andy
Technical Details
Message-ID:
<90May7.072047edt.19230@me.utoronto.ca>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!me!sunReferences:
<90122.175401MCCABE@MTUS5.BITNET> <10153.26405d35@vax1.cc.lehigh.edu> <1873@gannet.cl.cam.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!me!sun Newsgroups: comp.sys.ibm.pc.programmer From: sun@me.utoronto.ca (Andy Sun Anu-guest) Subject: Re: Current directory from batch file Message-ID: <90May7.072047edt.19230@me.utoronto.ca> Organization: University of Toronto, Department of Mechanical Engineering References: <90122.175401MCCABE@MTUS5.BITNET> <10153.26405d35@vax1.cc.lehigh.edu> <1873@gannet.cl.cam.ac.uk> Date: 7 May 90 11:21:17 GMT