This article describes a special feature of the Windows
Command Prompt called the File and Path Completion
Characters, which allow you to enter file and folder names
by typing in just a few characters instead of the entire
file or folder name. This article will be useful to you if
you use the Command Prompt already and want to save some
keystrokes. If you don’t already use the Command Prompt,
this article will not likely provide much benefit to you,
and, since it entails editing the Registry, may even be
hazardous to the health of your computer if you mess
something up, so please proceed with caution!
Prerequisites
We’ll assume for this article that you already understand
the basics of the Command Prompt:
- Starting the Command Prompt, using Start / All Programs /
Accessories / Command Prompt.
- Running commands at the Command Prompt, by typing the
command and any parameters followed by the Enter key, such
as
dir c:\ ENTER.
- Exiting the Command Prompt, by typing
exit (followed by ENTER).
- Listing the available commands, by typing
help (followed
by ENTER).
- Getting help on a particular command, by typing
help
followed by the command name, such as help dir.
- Getting help on a particular command using an alternative
method, that being typing the name of the command followed
by
/?, such as dir /?.
- Using basic commands such as
dir, chdir/cd, mkdir/md,
rmdir/rd, del, move, copy, tree, etc.
We will need to make two small changes to the Registry
to accomplish our goal, so we also assume you can do the
following in a safe and responsible manner:
- Start the Registry Editor (regedit.exe) by typing REGEDIT
into the Start / Run box.
- Add or change DWORD Values in the Registry Editor.
- Exit the Registry Editor.
- Not mess up your entire Windows Operating System by using
the Registry Editor.
If any of these assumptions are not true for you, you may
want to check on the Internet or in the Windows XP Help and
Support Center for information about the Windows Command
Prompt and the Registry Editor. You may also want to skip to
the next article. The Command Prompt and the Registry Editor
are not for beginners. You CAN get into trouble if you’re
not comfortable using either of them; therefore, please be
sure you are comfortable with this material before trying
the techniques detailed in this article. If you’ve never
used the Command Prompt before, this is probably not a good
time to start, and the information in this article probably
does not provide a significant enough benefit to warrant
bothering. If, on the other hand, you are comfortable using
the Command Prompt and the Registry Editor and are looking
to save some keystrokes, read on. If you stick to the path,
you should be fine. Just please don’t come to me, or my
editor/publisher, with a lawyer if you mess up your
computer!
Using File and Path Names in the Command Prompt WITHOUT the
Completion Characters
Without using Completion Characters, if you want to list the
contents of a folder that has a long name, you are required
to type the entire name. For example, if you’d like to see
the contents of the C:\Documents and Settings\David folder
and your current directory is C:\, you must type DIR
"C:\Documents and Settings\David". (Yes, you could make
use of the * and ? wildcard characters to some
extent, but that‘s a subject for another article….)
Figure 1 – Typing Folder Names Without Completion Characters
You’ve got to spell it exactly correctly, or else you’ll see
a File Not Found message.
Figure 2 – DIR Command with a Misspelled Folder Name
Well, perhaps your spelling isn’t that good, or maybe you
don’t type that quickly. Completion Characters to the
rescue!
Completion Characters
The Windows Command Prompt has a new feature called File and
Path Completion Characters that lets you type in just a few
of the characters of the folder or file name, hit a special
key (of your choosing), and the Command Prompt will complete
the rest for you. For example, on my machine, I can type DIR
C:\Doc<Ctrl-D>\D<Ctrl-D> ENTER to get the same result as
typing the entire line DIR "C:\Documents and
Settings\David". This is because I’ve configured the Ctrl-D
key sequence to be my Path Completion Character, or what I
like to think of as my Directory Completion Character,
hence the Ctrl-D. You do this by creating or changing a
Registry value.
Choosing the Keystrokes for Your Completion Characters
There are two completion character settings available for
your use – one which completes File names and another which
completes Folder names (also known as Path or Directory
names). You can configure which keys you want to use for
these completion operations, or you can turn the features
off completely (by setting them to 0). I like to use Ctrl-F for Filename Completion
and Ctrl-D for Path (Directory) Completion. To make the
keystroke selection, you must program the ASCII code of the
desired keystroke into the Registry. Ctrl-A is ASCII 1,
Ctrl-B is ASCII 2, and so on. Ctrl-D therefore is ASCII 4, while
Ctrl-F is ASCII 6.
We’re almost ready to program the selections into the
Registry. One last decision to be made is if you want these
selections to apply to the currently logged-in user only or
to all users on the machine. The answer to that question
determines whether to use the HKEY_CURRENT_USER or the
HKEY_LOCAL_MACHINE Registry hive.
An Example
WARNING!!! REGISTRY CHANGES AHEAD!!! PROCEED WITH CAUTION
AND AT YOUR OWN RISK!!!
So let’s suppose for the sake of this example that you want
to use Ctrl-F for Filename Completion and Ctrl-D for
Directory (Path) Completion, and that you want this to take
effect only for yourself, the currently logged-in user. Of
course, in order to do this, you must have sufficient rights
on your machine to edit your registry. If you’re in a
tightly restricted office environment, you may not be able
to do this.
These are the steps to perform for our example:
- Select
Start / Run.
- Type
REGEDIT and press ENTER.
- Navigate to the
HKEY_CURRENT_USER hive.
- Open the
Software\Microsoft\Command Processor key.
- Let’s do the Filename Completion character first. Check
to see if there is a DWORD Value named
CompletionChar. This
is the name of the Registry value for Filename Completion. If it
already exists, skip to Step 8.
- To create the new value, select
Edit / New / DWORD
Value.
- Change the name of the new value from
New Value #1 to
CompletionChar by typing CompletionChar and pressing ENTER.
Be sure to spell this correctly or else the technique will
not work.
- OK, now that the CompletionChar Value exists, select
Edit / Modify.
- Select
Decimal entry as the Base so you don’t have to
worry about Hexadecimal conversion.
- Enter the ASCII code you selected for the Filename
Completion Character in the Value Data textbox. In our
example, we’ve selected 6 for
Ctrl-F.
- Click OK. One down, one to go!
- Now let’s do the Folder (Path) Completion character.
Check to see if there is a DWORD Value named
PathCompletionChar. This is the name of the Registry value for
Folder (Path) Completion. If it already exists, skip to Step
15.
- To create the new value, select
Edit / New / DWORD
Value.
- Change the name of the new value from
New Value #1 to
PathCompletionChar by typing PathCompletionChar and pressing
ENTER. Be sure to spell this correctly or else the technique
will not work.
- OK, now that the PathCompletionChar Value exists, select
Edit / Modify.
- Select
Decimal entry as the Base so you don’t have to
worry about Hexadecimal conversion.
- Enter the ASCII code you selected for the Folder (Path)
Completion Character in the Value Data textbox. In our
example, we’ve selected 4 for
Ctrl-D.
- Click OK.
- You’re all done, so exit the Registry Editor using
File
/ Exit.
- The changes take effect in any new Command Prompt
windows you open, so select
Start / All Programs /
Accessories / Command Prompt.
Figure 3 – Registry Editor Showing HKEY_CURRENT_USER\Software\Microsoft\Command Processor
A Demonstration of How to Use the Completion Characters
To see these completion characters in action, you type just
the first few letters of the file or folder you’re looking
for, and then press the appropriate completion character.
The Command Prompt will fill in the rest of the file or
folder name. If there is more than one match, you can press
the same key repeatedly until you find the one you’re
looking for.
Let’s look at an example. On my machine, the root folder of my
hard drive looks like this:
Figure 4 – A Directory Listing of the Root Folder of My Hard Drive
So, at a Command Prompt, I can type DIR D and then hit Ctrl-D and it will be as if I had typed DIR Data. If I then hit
Ctrl-D again, it will change to DIR Debug, and once more
will give me DIR DELL. When I find the one I want, I can hit
ENTER, just as if I had typed the folder name myself.
If I want specifically the Windows folder and not the Web
folder, I can type DIR wi and hit ENTER to skip the Web
folder and go straight to Windows.
If I want to see a file that is called Letter to Bob
Smith.doc in my current folder, I can type DIR L and press
Ctrl-F for Filename Completion. Notice the Ctrl-F key will
list Folders in addition to Files when used with most
commands, except for the commands that specifically work on
Folders, such as CHDIR, MKDIR, and RMDIR, in which case it
will only list Folders, which may be a little confusing, but
makes sense!
Last Words
Note that any completion character selections you make
in HKEY_CURRENT_USER will override corresponding selections
in HKEY_LOCAL_MACHINE.
To disable the use of either Completion Character, set the corresponding Registry value to 0.
Don’t forget to use the EXIT command to close your Command
Prompt windows when you’re finished with them.
And again, please be careful when editing the Registry and
using the Command Prompt.
Hope this article saves you some keystrokes and some time in
your busy day!

|