Extended Directory Searches
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: it checks to see whether you have specified either the
name of an existing subdirectory below the current directory, or the name
of an existing directory with a full path or a drive letter. If you have,
the command processor changes to that directory, and does no further
searching.
This traditional search method requires that you navigate manually through
the directory tree, and type the entire name of each directory you want to
change to. Extended Directory Searches speed up the navigation process
dramatically by allowing the command processor to find the directory you
want, even if you only enter a small part of its name.
When the traditional search method fails, CMD.EXE try to find the
directory you requested via the CDPATH, then via an Extended Directory
Search. This section covers only Extended Directory Searches, which are
more flexible and more commonly used than CDPATH.
Extended Directory Searches use a database of directory names to
facilitate changing to the correct directory. The database is used only
if Extended Directory Searches are enabled, and if the explicit directory
search and CDPATH search fail to find the directory you requested.
An extended directory search automatically finds the correct path to the
requested directory and changes to it if that directory exists in your
directory database. If more than one directory in the database matches
the name you have typed, a popup window appears and you can choose the
directory you want.
You can control the color, position and size of the popup directory search
window from the Command line 2 page of the OPTION dialogs, or with
directives in the .INI file, including CDDWinLeft, CDDWinTop, CDDWinWidth,
and CDDWinHeight, and CDDWinColors. You can also change the keys used in
the popup window with key mapping directives in CMD.INI.
To use extended directory searches, you must explicitly enable them and
also create the directory database.
The Extended Search Database
To create or update the database of directory names, use the CDD /S
command. When you create the database with CDD /S, you can specify which
drives should be included. If you enable Extended Directory Searches and
do not create the database, it will be created automatically the first
time it is required, and will include all local hard drives.
The database is stored in the file JPSTREE.IDX, which is placed in the
root directory of drive C: by default. The same tree file is used by all
JP Software command processors. You can specify a different location for
this file on the Command Line 2 page of the OPTION dialogs, or with the
TreePath .INI directive. If you are using 2 or more of our products on
your computer and want to have different drives stored in the database for
each, use the dialogs or the TreePath directive to place their database
directories in different locations.
If you use an internal CMD.EXE command to create or delete a directory,
the directory database is automatically updated to reflect the change to
your directory structure. The updates occur if the command processor can
find the JPSTREE.IDX file in the root directory of drive C: or in the
location specified by the TreePath .INI directive.
The internal commands which can modify the directory structure and cause
automatic updates of the file are MD, RD, COPY /S, DEL /X, MOVE /S, and
REN. The MD /N command can be used to create a directory without updating
the directory database. This is useful when creating a temporary
directory which you do not want to appear in the database.
Enabling Extended Searches
To enable extended directory searches and control their operation, you
must set the FuzzyCD directive in the .INI file. You can set FuzzyCD with
the Search Level option on the Command Line 2 page of the OPTION dialogs,
or by editing the .INI file manually.
If FuzzyCD = 0, extended searches are disabled, the JPSTREE
database is ignored, and CD, CDD, PUSHD, and automatic directory
changes search for directories using only explicit names and
CDPATH. This is the default.
If FuzzyCD = 1 and an extended search is required, then the
command processor will search the JPSTREE database for directory
names which exactly match the name you specified.
If FuzzyCD = 2 and an extended search is required, the command
processor will search the database for exact matches first, just
as when FuzzyCD = 1. If the requested directory is not found, it
will search the database a second time looking for directory names
that begin with the name you specified.
If FuzzyCD = 3 and an extended search is required, the command
processor will search the database for exact matches first, just
as when FuzzyCD = 1. If the requested directory is not found, it
will search the database a second time looking for directory names
that contain the name you specified anywhere within them.
For example, suppose that you have a directory called C:\DATA\MYDIR,
CDPATH is not set, and C:\DATA is not the current directory on drive C:.
The following chart shows what CDD command you might use to change to
this directory.
FuzzyCD
Setting CDD Command
0 [c:\] cdd c:\data\mydir
1 [c:\] cdd mydir
2 [c:\] cdd myd
3 [c:\] cdd yd
An extended directory search is not used if you specify a full directory
path (one beginning with a backslash [\], or a drive letter and a
backslash). If you use a name which begins with a drive letter (e.g.
C:MYDIR ), the extended search will examine only directories on that
drive.
Forcing an Extended Search with Wildcards
Normally you type a specific directory name for the command processor to
locate, and the search proceeds as described in the preceding sections.
However, you can also force the command processor to perform an extended
directory search by using wildcard characters in the directory name. If
you use a wildcard, an extended search will occur whether or not extended
searches have been enabled.
When CMD.EXE is changing directories and it finds wildcards in the
directory name, it skips the explicit search and CDPATH steps and goes
directly to the extended search.
If a single match is found, the change is made immediately. If more than
one match is found, a popup window is displayed with all matching
directories.
Wildcards can only be used in the final directory name in the path (after
the last backslash in the path name). For example you can find
COMM\*A*.* (all directories whose parent directory is COMM and which have
an A somewhere in their names), but you cannot find CO?M\*A*.* because it
uses a wildcard before the last backslash.
If you use wildcards in the directory name as described here, and the
extended directory search database does not exist, it will be built
automatically the first time a wildcard is used. You can update the
database at any time with CDD /S.
Internally, extended directory searches use wildcards to scan the
directory database. If FuzzyCD is set to 2, an extended search looks for
the name you typed followed by an asterisk (i.e. DIRNAME*). If FuzzyCD
is set to 3, it looks for the name preceded and followed by an asterisk
(i.e. *DIRNAME*).
These internal wildcards will be used in addition to any wildcards you
use in the name. For example if you search for ABC?DEF (ABC followed by
any character followed by DEF) and FuzzyCD is set to 3, the command
processor will actually search the directory database for *ABC?DEF*.
Disabling Extended Searches in Batch Files
When writing batch files you may want to use the CD or CDD command to
switch directories without triggering an extended search. For example,
you may need the search to fail (rather than search the extended search
database) if a directory does not exist, or you may want to ensure that
the extended search popup window does not appear in a batch file designed
to run in unattended mode.
To disable extended searches, use the /N option of CD or CDD. When this
option is used and a directory does not exist below the current directory
or on the CDPATH, the command will fail with an error message, and will
not search the extended search database. For example this command might
trigger an extended search:
cdd testdir
but this one will not:
cdd /n testdir
Note that this option is not available for PUSHD. To perform the same
function when using PUSHD, save the current directory with PUSHD (without
parameters) and then use CDD /N to change directories, for example:
pushd
cdd /n testdir
Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs