🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How can I get current directory??

#7992
From: John Savage
Date: Thu, 29 Feb 1996 00:00
31 lines
1882 bytes
]Jerry Marr  <marr@adpt.com> wrote:
]>from a DOS command file, can I save away the current directory so that I
]>can then change my directory and later change back to where I started from?
]>
]>I tried:
]>
]>set wd=.
]>cd/d <newdirectory>
]>..
]>..
]>cd/d %wd%
]>
]>but it evaluates the "." when it is used, not when it is initially set.  Thus,
]>the last command above was a no-op.

You can create a separate batch file to do this and then execute it with
CALL PUSH.BAT -- or else incorporate these two lines into any batch file:

PUSH.BAT
--------
echo @echo off>pop.bat
command/e:1024 /cfor %%i in (1 2) do
               prompt $n:$_CD $p$_|find/v "prompt ">>pop.bat

(Join what I have shown as two broken lines into one long line.)

When called, this creates a file POP.BAT -- and later execution of POP
will return you to your original drive and directory. (Just make sure
that you create the file POP.BAT where it can be found on your path.)
--
John Savage               koala@sydney.dialix.com.au
Technical Details
Message-ID: <4h3vv3$b9p$1@sydney.DIALix.oz.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <58759.microtsk@fox.nstn.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10f6aa,d4f8682dc43434cd
X-Google-Attributes: gid10f6aa,public
X-Google-Thread: 10d683,a268e25da24cb6a,start
X-Google-Attributes: gid10d683,public
X-Google-Thread: f53ba,a268e25da24cb6a,start
X-Google-Attributes: gidf53ba,public
X-Google-Thread: f71eb,a268e25da24cb6a,start
X-Google-Attributes: gidf71eb,public
From: John Savage <koala@sydney.dialix.com.au>
Subject: Re: How can I get current directory??
Date: 1996/02/29
Message-ID: <4h3vv3$b9p$1@sydney.DIALix.oz.au>
X-Deja-AN: 141587198
sender: koala@sydney.DIALix.oz.au
references: <58759.microtsk@fox.nstn.ca>
followup-to: comp.os.msdos.programmer,comp.os.msdos.misc
organization: Gumleaf Smoke Signals Telegraph Co.
newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc,comp.sys.ibm.pc.misc,aus.computers.ibm-pc