Using the change directory (CD) command to navigate between folders can be a very daunting task—especially if the path is made up of long folder names. Not only does it take you a while to type out the long pathname, but whenever you make one little typo, you have to start all over. If you spend any amount of time working in a Command Prompt window in Windows NT4/2K/XP, you’ll definitely want to take advantage of the File And Directory Name Completion feature built into the operating system.

The Command Prompt’s File And Directory Name Completion feature is basically a quick search feature that allows the command processor, Cmd.exe, to complete the names of files and folders as you type at the command prompt. Unfortunately, the File And Directory Name Completion feature isn’t enabled by default. In order to take advantage of this feature, you have to know that it exists and you have to know how to enable it, which is done by tweaking a setting in the registry.

If you’re using Windows NT4, tweaking the registry is the only way to enable the File And Directory Name Completion feature. While the same tweak will also work in Windows 2000 and Windows XP, these operating systems provide you with a simple command line switch for temporarily enabling and disabling the File And Directory Name Completion feature. While the result of this temporary feature is the same, it’s implemented a bit differently.

In this article, I’ll show you how to permanently enable and use the File And Directory Name Completion feature in Windows NT4/2K/XP. In addition, I’ll explain how to enable and use the temporary File And Directory Name Completion feature in Windows 2000 and Windows XP.


Caveat

Since editing the registry can be dangerous, you should consider making a full backup before you attempt this operation. If you’re using Windows XP, you can simply use System Restore to create a restore point.


Enabling the feature
Enabling the File And Directory Name Completion feature by tweaking the registry is a pretty straightforward procedure. To begin, access the Run dialog box by selecting the Run command on the Start menu or by pressing [Windows]R. Next, launch the Registry Editor by typing regedit.exe in the Open text box and clicking OK.

Once you have the Registry Editor up and running, locate and double-click on the key HKEY_CURRENT_USER to expand its subtree. When this subtree is visible, open each of the following subtrees in succession:

  • Software
  • Microsoft
  • Command Processor

Once you open the Command Processor subkey, locate and double-click the CompletionChar value. When you see the Edit DWORD Value dialog box, change the number in the Value Data text box from 0 to 9, as shown in Figure A.

Figure A
To enable the File And Directory Name Completion feature, you’ll change the CompletionChar value setting to 9.

To continue, click OK to close the Edit DWORD Value dialog box and then close the Registry Editor. While this change should be implemented immediately, you may want to restart your system, just to be sure.

Using the feature
As I mentioned, the File And Directory Name Completion feature is designed to automatically complete the names of files and folders as you type at the command prompt. Once you enable the File And Directory Name Completion feature in the registry, it will be available every time you open a Command Prompt window.

Using it is easy. When you’re typing a filename or a folder name, you can now press [Tab] and Cmd.exe will search for and display the filename or folder name in the current directory that most closely matches the string that you’ve typed on the command line. If there are multiple matches, you can successively display each one of them by continuing to press [Tab].


An alternate keystroke

Keep in mind that while pressing [Tab] will move you forward and eventually cycle through all of the matches, you can go backwards through the matches at any time by pressing [Shift][Tab].


The File And Directory Name Completion feature is even intelligent enough to discern, based on the command that you’re using, when you want to work with a file and when you want to work with a folder. For example, if you’re in the root directory of drive C and want to change to the Program Files folder, you type cd pro, then press [Tab], and the File And Directory Name Completion feature will instantly complete the folder name, as in:
cd “Program Files”

The quotation marks are automatically added due to the fact that the folder name has a space in it. Keep in mind that the File And Directory Name Completion feature processes matches alphabetically. As such, if there is a folder named Proactive in the root directory, it will appear at the command prompt before Program Files will.

Working with files is just as easy. For example, suppose that you want to list the contents of the Product.txt file. If so, you’d type the command type pro and then press [Tab]. When you do, the File And Directory Name Completion feature will instantly complete the filename, as in:
type Product.txt

Now, it’s important to keep in mind that when it comes to using a command related to files, once the File And Directory Name Completion feature runs out of matching filenames, it will begin displaying matching folder names. However, if you’re using a command related to folders and continue cycling through the list, you’ll never see any filenames.


No matches

If there are no matches in the current directory, pressing [Tab] will elicit a single beep.


Listing files
You can also use the File And Directory Name Completion feature to individually list all the files in a folder or as a filter to quickly locate specific files. To perform the file-listing operation, you simply press [Tab]. As you do, each file in the folder will individually appear at the command prompt.

To perform the file-filtering operation, you simply type the first couple of letters in the files you’re interested in and press [Tab]. As you do, files with those letters individually appear at the command prompt.

You can even use wildcard characters to narrow your filter operation. For example, if you want to see all the files in a folder that have the .txt extension, you can type: *.txt and then press [Tab]. Then the File And Directory Name Completion feature will individually display only those files that have the .txt extension.

The temporary switch
Finally, if you’re using Windows 2000 or Windows XP and for some reason don’t want to permanently enable the File And Directory Name Completion feature, you can enable and disable it on the fly with a command line switch. When you do so, the File And Directory Name Completion feature will only be enabled for the current Command Prompt session. Once you close the Command Prompt window, the feature is disabled.

To temporarily enable the File And Directory Name Completion feature, you’ll begin by opening a Command Prompt window as you normally would. Then, at the prompt, you’ll type the command:
cmd /f:on

Now, to disable the File And Directory Name Completion feature, you’ll type the command at the command prompt:
cmd /f:off

While the basic function of the temporary File And Directory Name Completion feature is identical to the permanent solution, the keystrokes that you use to implement it are different. For directory name completion, you use [Ctrl]D, while for file name completion you use [Ctrl]F. You can move through the list backwards, by pressing [Shift] and [Ctrl]D or [Ctrl]F simultaneously.