[Toc][Index]

CDPATH


When you change directories with an automatic directory change, CD, CDD, 
or PUSHD command, CMD.EXE must find the directory you want to change to. 
 To do so, the command processor first uses the traditional method to find 
a new directory. 
When the traditional search method fails, CMD.EXE tries to find the 
directory you requested via the CDPATH, then via an Extended Directory 
Search.  This section covers only the CDPATH. 
Enabling both CDPATH and Extended Directory Searches can yield confusing 
results, so we recommend that you do not use both features at the same 
time. If you prefer to explicitly list where the command processor should 
look for directories, use CDPATH.  If you prefer to have the command 
processor look at all of the directory names on your disk, use Extended 
Directory Searches. 
CDPATH is an environment variable, and is similar to the PATH variable 
used to search for executable files:  it contains an explicit list of 
directories to search when attempting to find a new directory.  The 
command processor appends the specified directory name to each directory 
in CDPATH and attempts to change to that drive and directory.  It stops 
when it finds a match or when it reaches the end of the CDPATH list. 
CDPATH is ignored if a complete directory name (one beginning with a 
backslash [ \]) is specified, or if a drive letter is included in the 
name.  It is only used when a name is given with no drive letter or 
leading backslash. 
CDPATH provides a quick way to find commonly used subdirectories in an 
explicit list of locations.  You can create CDPATH with the SET command. 
 The format of CDPATH is similar to that of PATH:  a list of directories 
separated by semicolons [;].  For example, if you want the directory 
change commands to search the C:\DATA directory, the D:\SOFTWARE 
directory, and the root directory of drive E:\ for the subdirectories that 
you name, you should create CDPATH with this command: 


        [c:\] set cdpath=c:\data;d:\software;e:\

Suppose you are currently in the directory C:\WP\LETTERS\JANUARY, and 
you'd like to change to D:\SOFTWARE\UTIL.  You could change directories 
explicitly with the command: 


        [c:\wp\letters\january] cdd d:\software\util

However, because the D:\SOFTWARE directory is listed in your CDPATH 
variable as shown in the previous example (we'll assume it is the first 
directory in the list with a UTIL subdirectory), you can simply enter the 
command 


        [c:\wp\letters\january] cdd util

or, using an automatic directory change: 



        [c:\wp\letters\january] util\

to change to D:\SOFTWARE\UTIL. 
As it handles this request, the command processor looks first in the 
current directory, and attempts to find the C:\WP\LETTERS\JANUARY\UTIL 
subdirectory.  Then it looks at CDPATH, and appends the name you entered, 
UTIL, to each entry in the CDPATH variable -- in other words, it tries to 
change to C:\DATA\UTIL, then to D:\SOFTWARE\UTIL.  Because this change 
succeeds, the search stops and the directory change is complete. 

Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs