Dec 142017
 
Stores current DIR to a environment variable. Great for batch files.
File GETDIR.ZIP from The Programmer’s Corner in
Category Batch Files
Stores current DIR to a environment variable. Great for batch files.
File Name File Size Zip Size Zip Type
GETDIR.COM 542 511 deflated
GETDIR.TXT 2348 977 deflated

Download File GETDIR.ZIP Here

Contents of the GETDIR.TXT file



GETDIR Ver. 1.0
(c) Copyright 1986
William C. Parke
for CHUG
Capitol Heath Users' Group

GETDIR is a batch file utility to make the current drive index
and directory name available to batch files and other programs which
utilize the MS-DOS Environment. The drive and directory are placed
into the Environment Variables DRIV and DIR. These are then
accessible to BAT files by using per cent signs surrounding the
variable name.

GETDIR requires no command line string. If any character follows
the command, a help display will be sent to the console. GETDIR can
be used any number of times in succession. Each time, the DRIV and
DIR variables are separately redefined. If there is no more
Environment space, GETDIR will generate an ERRORLEVEL=1. If no
directory name is found or the system is in the root directory, then
DIR will be set to the period character.

Example fragments from batch file applications are shown below:

Example 1: Display current drive and directory:

ECHO OFF
GETDIR
ECHO Current Drive is %DRIV%:
ECHO Current Directory is %DIR%
...

Example 2: Checking directory from console input:

ECHO OFF
:AGAIN
INPUT Give new subdirectory:
SET NDIR=%ANS%
CD %NDIR%
GETDIR
IF %NDIR%==%DIR% GOTO OK
INPUT Directory not found. Create it? /1
IF %ANS%==Y GOTO MK
GOTO EXIT
:MK
MKDIR %NDIR%
CD %NDIR%
:OK
ECHO Now in %NDIR%
...
:EXIT

The utility INPUT for console input to a BAT file is available through
CHUG at the address below.

Example 3: Back tracing a directory branch:

ECHO OFF
:START
GETDIR
IF %DIR%==. GOTO FIN
SET DT=%DIR%
CD ..
:LOOP
GETDIR
ECHO Now in %DIR%
IF %DIR%==. GOTO FIN
SET DT=%DIR%\%DT%
CD ..
GOTO LOOP
:FIN
ECHO Current directory path is %DT%
CD .%DT%
GETDIR
ECHO Back in %DIR%
...

Comments may be sent to the author via CHUG, Capital Heath Users'
Group, P.O. Box 16406, Arlington, VA 22215-1406.


 December 14, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)