One of the most clumsy aspects of using the Windows command line is traversing the file system directories. Here are a few tips to save some keystrokes and time.
1) Use directory name masking. Did you know that you can use * as a mask in the CD command?
Example: cd \brainstrain
This can be shortened to cd \br*
The typed out portion must be unique or it will change to the first directory name that matches the mask.
2) When you CD to a long directory name with spaces in it where you would quote the name like "program files" you can leave out the last quote.
Example: cd "\program files"
can be shortened to cd "\program files
and... using tip 1 and 2, you can do this cd "\prog*
3) You can drag and drop a folder from Explorer into a CMD window. Windows will paste in the full directory path including quotes. Once the path is in the CMD window, change focus to the CMD window, hit HOME to get to the beginning of the cmd line, then type cd /d (with insert on), then hit enter.
Note: the /d option of the cd command is only required if you included the drive letter in the path AND the drive is different than the current drive.
This is the XP version that also works in Windows 2000 (afaik). With this power toy, you simply right click on a folder name in Explorer, then click Open Command Window Here. A new CMD window will be opened with the folder being the current directory.
5) Use environment variables. The following changes to the temp directory: cd %temp% or, change to the user profile directory: cd %userprofile%
Note - Don't use the masking methods in batch files because as directories are added or changed, the mask may not change to the directory name you would expect. Always spell everything out in full in batch files.
These methods work in Windows 2000 and later operating systems (however... not tested with Vista).
Enjoy!
Look for more Killer Command Line Tips in the near future.
Didn't find what you were looking for? Try searching or posting a question in the HowToFixYourStuff Forum.
READER COMMENTS
No comments yet. Be the first to comment on this by using the form below.Comment Posting Guidelines: Please only post comments relevant to this article. Registration is not necessary to
post comments, however, a valid email address is required, but will not be shown here or published in any way. HTML and URLs are not supported.
Rules: No obscene, inflammatory or offensive content allowed. All comments are subject to review by a systematic process and/or human
before being published. Any abuse of this is subject to being banned and reported. The use of the form below assumes
the acceptance of these rules.
Did You Know... That a Top Fuel car can cost over $3,000 per quarter mile, 300 MPH, 4 second pass? (Includes wear on engine, tires, clutch, gears. NOT including expenses such as crew and drivers salaries, transportation, accommodations, uniforms, or the cost of the car itself!)