Category : Batch File Utilities - mostly for DOS
Archive   : BATUTIL.ZIP
Filename : GETDIR.MOD

 
Output of file : GETDIR.MOD contained in archive : BATUTIL.ZIP
MODULE getdir;
(*
Title : getdir
Author : Randall A. Maddox
12209 M Peach Crest Drive
Germantown, MD 20874
(301) 428-9581

System: LOGITECH MODULA-2, MS/PCDOS, Version 3.03, December 1987

Description:
The purpose of this program is to get the current drive and directory and
store them in a text file called restdir.bat. The point to this is that you
can set up a .bat file to execute some program and then return back to the
drive and directory you were in originally by including the command restdir
at the end of the .bat file. This program runs under MSDOS 2.0 or later.
Here is a sample:

My .bat files are stored in a directory called c:\util. One of those .bat
files is called ws.bat and executes WordStar. Here is what it looks like:

echo off
getdir > c:\util\restdir.bat (note the redirection of output)
c:
cd \wordproc
ws
restdir

Here is what the file restdir.bat that getdir creates looks like:

echo off
:
cd
cls

is the drive I started on as determined by getdir and
is the directory I started in. The upshot of all this is that
after running WordStar I end up right back where I was with a clean
screen.

You can redirect the output of getdir to whatever .bat file you wish.
I just use c:\util because it is in my PATH so that I can call restdir
without using its path name. Of course, you needn't call the .bat file
restdir.bat either.

Hope you find this program useful. If you turn up any bugs, please let
me know. Thanks.

Update History:
Original version: 5/16/87 by Randy Maddox
Last update: 5/17/87 by Randy Maddox
Rewrote to allow redirection of output: 7/29/87 by Randy Maddox

*)

FROM Strings IMPORT
Concat;

FROM InOut IMPORT
WriteString,WriteLn;

FROM DiskDirectory IMPORT
CurrentDrive,CurrentDirectory;

VAR
Path : ARRAY [0..65] OF CHAR; (* current directory *)
Drive : CHAR; (* current drive *)
I : CARDINAL;

BEGIN (* MAIN BODY getdir *)

(* first get current drive and directory *)
CurrentDrive(Drive); (* returns drive as uppercase character *)
CurrentDirectory(Drive,Path); (* returns directory path from \ *)
Concat('\',Path,Path); (* insert \ in front of path *)

(* now we write out the .bat file used to restore this directory *)
WriteString('echo off');
WriteLn;
WriteString(Drive);
WriteString(':');
WriteLn;
WriteString('cd ');
WriteString(Path);
WriteLn;
WriteString('cls'); (* and we're all done *)

END getdir.

(* end of this file *)


  3 Responses to “Category : Batch File Utilities - mostly for DOS
Archive   : BATUTIL.ZIP
Filename : GETDIR.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/