Windows Command Line Auto Completion

xplogoAlthough I think this is one of the best new features in the Windows XP CMD, a lot of people still don’t know the auto completion of cmd.exe. You’re only one minute away from a trick, which could save you a few minutes per day!

The easiest way to explain this is to jump in feet first:

  • Open a command line (<Windows Key>-R, CMD, <Enter>)
  • At the prompt, repeatedly hit tab

You will be cycling through all of the files and directories in your current directory. Now try this:

  • At a clean command prompt, type “dir \P” then start hitting tab.

Now you’ll be cycling through all the directories that start with “P” in the root of the current drive. You’ll also notice that for files with embedded spaces, quotes are automatically added. This works for as many characters as you wish to type. After you cycle to the directory you want, type a backslash, then hit tab again and you’ll cycle through the files and sub-directories in that directory, and so on. On my current machine, I can type the following to open my machine.config:

notepad \win<tab>\mic<tab>\<tab>\v1.1<tab>\con<tab>\m<tab><enter>

This results in the following command line, which would take considerably more keystrokes or mouse clicks:

notepad \WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config

This works at just about any point in a command, as long as you are starting from a space. It will also work on UNC paths staring at the share name (Assuming you can authenticate to that particular share):

dir \\fileserver\share\<tab>

There may be a delay as CMD goes an enumerates the items on the share, but if you are trying to get to something deep down in some huge directory structure with really long path names, this helps a ton.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x