Using the change directory (CD) command to navigate between folders can be a daunting task—especially if the path is made up of long folder names. It takes you a while to type out the long pathname, and 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 in to the operating system.
The 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, File And Directory Name Completion isn’t enabled by default. To take advantage of this feature, you have to know how to enable it 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 File And Directory Name Completion. While the result of this temporary feature is the same, it’s implemented a bit differently.
Let’s discuss how to permanently enable and use File And Directory Name Completion 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.
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 File And Directory Name Completion 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:
- 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.
|To enable File And Directory Name Completion, you’ll change the CompletionChar value setting to 9.|
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, File And Directory Name Completion is designed to automatically complete the names of files and folders as you type at the command prompt. Once you enable File And Directory Name Completion 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].
File And Directory Name Completion 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 File And Directory Name Completion processes match 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, File And Directory Name Completion will instantly complete the filename, as in:
Now, it’s important to keep in mind that when it comes to using a command related to files, once File And Directory Name Completion 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.
If there are no matches in the current directory, pressing [Tab] will elicit a single beep.
You can also use File And Directory Name Completion 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 File And Directory Name Completion 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 File And Directory Name Completion, you can enable and disable it on the fly with a command line switch. When you do so, File And Directory Name Completion will be enabled only for the current Command Prompt session. Once you close the Command Prompt window, the feature is disabled.
To temporarily enable File And Directory Name Completion, you’ll begin by opening a Command Prompt window as you normally would. Then, at the prompt, you’ll type the command:
To disable File And Directory Name Completion, you’ll type the command at the command prompt:
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.