Tip: File Name and Folder Name Completion at the Command Prompt

Follow Our Daily Tips

Twitter | Blog | RSS | Facebook

Command Prompt offers an invaluable file-name and folder-name completion feature that can save you the trouble of typing long paths or file names. If you start typing a command string and then press Tab (the default completion character), Command Prompt proposes the next file or folder name that’s consistent with what you’ve typed so far. For example, to switch to a folder that starts with the letter Q, you can type cd q and then press the folder-name completion character as many times as necessary until the folder you want appears.

While the completion character for file names and folder names is the Tab key by default. You can select a different completion character by modifying the CompletionChar and PathCompletionChar values in the HKCU\Software\Microsoft\Command Processor registry key. These DWORD values specify the file and folder completion characters, respectively, for the current user. (To change the settings for all users, modify the same values in HKLM\Software\Microsoft\Command Processor.)

Keep in mind that if CompletionChar is defined and PathCompletionChar is either absent or set to the hexadecimal value 0x40, the CompletionChar setting will work for both file completion and folder completion. In all cases, the completion characters should be specified as hexadecimal values—such as 0x9 for Tab, 0x4 for Ctrl+D, 0x6 for Ctrl+F, 0xC for Ctrl+L, and so on.

You can also override the registry settings for an individual Command Prompt session by starting the session with Cmd /F:on or Cmd /F:off. Cmd /F:on starts a Command Prompt session with Ctrl+D as the path-completion character and Ctrl+F as the file-completion character, disabling the completion characters set in the registry. Cmd /F:off starts a Command Prompt session with no completion characters, regardless of your registry settings. Cmd /F:on and Cmd /F:off both disable the Tab key as a completion character.

From the Microsoft Press book Windows 7 Inside Out by Ed Bott, Carl Siechert, and Craig Stinson.

Looking for More Tips?

For more tips on using Microsoft products and technologies, visit the TechNet Magazine Tips library.