Tip of the Week: DOS Command Line Productivity Tricks

Blog Post created by ken_foster on Jan 3, 2015

Hello Community! Welcome to the first Tip of the Week for 2015.


I've been doing a lot of work in a DOS command window lately and I've learned a few things that have helped me be more productive. I thought I'd share some of them you. I hope you find them useful.


To reduce the amount of typing you have to do, there are a couple of useful function keys that are pre-defined on your DOS command shell:


  1. F3 -  Paste the last command you executed on the command line. Same as the up arrow, but easier to find on a laptop keyboard.
  2. F7 -  Pops a window up that has a numbered list of recently executed commands. Scroll to find what you want then press enter to execute it.
  3. F9 -  If you remember the number for the command you want (from the list when you pressed F7), you can execute it by pressing F9 and then enter the number.


There are other function keys defined, but these are the ones I use the most.


I find it easy to forget sometimes exactly what file system I'm in when I'm on a mapped drive. One trick I like to use is to modify the prompt so that when I'm on a remote file system I see the UNC path name instead of the drive letter. For example, the Z:\projects\> prompt becomes \\filesvr\mgc\projects Z:\>. Note that when I'm on a local drive, the prompt appears as simply driveletter:\path.


One of the best features in Windows is the Windows Explorer because it lets you see files and directories in a context of what's above them, beside them, and beneath them. In a DOS command shell, the tree command gives you that functionality. It's great for smaller directory structures as-is, but for larger ones you'll want to use it with a pipe  ( | more) or redirect the output to a file ( > filename.txt) as the scrolling capability is limited.


Give those a try! If you have any DOS commands you find useful, reply to this post and share them. I'm always looking for more.