Ch

PURPOSE   OPERATION   SETTING UP CDPATH   RELATED PROGRAMS


Author: Dan Mares, dmares @ maresware . com (you will be asked for e-mail address confirmation)
Portions Copyright © 1998-2020 by Dan Mares and Mares and Company, LLC
Phone: 678-427-3275

Purpose

This is a program to be used instead of the DOS cd (change directory) command. It is more intelligent and will increase the user's efficiency when using the change directory command.


top

Operation

This program DOES NOT work under NT operating systems.

The program works in conjunction with an environment variable called CDPATH. The CDPATH variable is made use of in much the same way as UNIX C shell makes use of the CDPATH variable.

You first set the environment variable CDPATH, then, instead of using the DOS cd command to change directories, you use the ch command to change directories.

The CDPATH is set to include directory paths using a similar format to the standard PATH=.... command. For instance, you might set the CDPATH to point to the parent of subdirectories which you routinely access.

The CH command then takes over, and does for cd (now you use ch instead of cd) what path does for locating programs.

When you key in a command to change directory such as ch directory, the ch command first looks at all subdirectories in the current working directory. And, like the cd command, if it finds a subdirectory it changes into it. Just like cd.

Here is where the enhanced capability comes in. What happens if the directory you are requesting is not a subdirectory of the current directory? DOS gives the nasty message “Invalid directory”, and does nothing. The ch command is a little more intelligent than that. It, like cd, first checks to see if the requested directory is a current subdirectory. If so, it changes to it and that's it. But if it is not a current subdirectory, it then checks the environment for a CDPATH environment variable.

If a CDPATH environment variable is set up, the program proceeds to check, in turn, each directory listed in the CDPATH variable. There can be up to 32. At the point that it finds the requested (CH) subdirectory in one of the listed directories, it then changes directory to that directory.

This is a highly efficient operation. If you have certain PARENT directories which you always work in, you can list them in the CDPATH environment. Then, no matter where you are in the disk, you just enter the command ch sub-direct and the ch command will change into it if the parent is listed in the CDPATH environment.

TRICK ON MAKING THIS LOOK JUST LIKE CD

This program is a real time saver: it eliminates having to type a lot of directory paths when using the normal cd command, and it eliminates typing errors, and forgotten paths to key sub directories.

If you are are technically comfortable with modifying the command.com file, do the following:

In COMMAND.COM, replace the CD command with CH.

Once the command.com internal CD is changed to CH, you can rename the CH.EXE program to CD.EXE.

Now, when you use the CD command, you are actually using the CH command that has been renamed. In order to maintain the integrity of the original command.com, it has been copied to cdcom.com. To get the system to use the cdcom.com file instead of command.com you use the shell= command. in the config.sys file to tell the operating system that you want cdcom used instead of command.com.

Once this is done, and you have renamed CH.EXE to CD.EXE, you have the capability of always working with an enhanced CD command, literally at your fingertips.


top

Setting up CDPATH

You must set a CDPATH environment variable. This is usually done in the autoexec.bat file.

Sample CDPATH setting:

set     CDPATH=c:\;d:\;d:\work\;d:\any_dir\sub_dir\;etc....\

The ideal format of the set CDPATH statement is with each directory ending with a backslash, and a semicolon between each path. Although the final backslash is not necessary, it makes the path look complete.

The ideal place for this set CDPATH command is obviously in the autoexec.bat file, so that the same paths get set up each time the computer is booted.

It is also advisable to copy the ch.exe program into a ram disk, and make that disk letter one of the first to be checked in your path=... command. This way, when you give the command ch directory the ch program can be found quickly (in ram disk) and executed.


top

Related Programs

None