By Robert Delwood
Senior Programmer Writer
The death of DOS has been widely announced or at least assumed. The arrival of Windows 95 formally replaced it.
Technically, DOS lingers on. Windows Vista still has the core files, but they’re accessable only from a special startup disk. Since Windows ME, DOS has been officially known as DOS 8.0. There is even a DOS 2000, published for legal reasons addressing the Year 2000 problem. The command line utility on the familiar DOS screen is available in all Windows versions, although the DOS functions are emulated rather than actual DOS, and the utility is now called the Windows Command Interpreter.
Many users assume that the functions of newer operating systems replace the DOS ones. For the most part, that’s true but not totally so. For example, deleting a folder by dragging it into the trash can automatically delete all the folders inside of it, but those folders are recoverable from the trash. In sharp contrast, the DOS Deltree command removes the files, and they are not recoverable. Dragging a folder to a new location is a simpler version of DOS’ Copy or Replace. Simpler but not completely the same. DOS commands have a purpose; some of the features are not entirely replaced by Windows equivalents and remain more convenient. For example, if service is performed on your computer, the first thing the technician does is open a command window and use IPCONFIG to get the current IP address. The following section gives useful DOS commands.
Using the Command Window
To use these DOS commands, click Start‑>Run to open the command window. Enter CMD in the Run screen, and click OK.
In many cases (as in the examples that follow) you will need to specify a path name to the file. The path includes the drive letter and a set of folders, such as D:MyProjectsMyCurrentProject. If a name contains a space, enclose the entire path or file name in quotation marks, such as “D:My ProjectsMy Current Project“.
And yes, the colors of the DOS window can be changed. Click the DOS window’s application icon in the upper left and select Properties. Click the Colors tab. In that tab, select Screen Text and a new color, and Screen Background and a new color. When you click OK, an Apply Properties screen displays. Select Save properties for future windows with same title and then OK.
Help is available for all commands. In the command window, enter the name of the command followed by /?, such as XCOPY /?.
This is perhaps the most useful command and offers a versatility that Windows doesn’t approach, even now. You can use it to copy more than one file, usually by copying folders, but with three main differences. First, it copies source files changed on or after a specified date only. If you do not include a date, it copies all source files that are newer than existing destination files; you can never accidentally replace a newer version with an older one. Second, it allows you to update only the files that have changed, saving time and possibly confirmation screens. Third, you can specify the file names to copy in the first place by using the DOS file name wildcard (such as *.doc? for all Word documents past and present). For example: to copy only the most recent file versions of all the files in a folder, use
XCOPY “D:Projects*.” “Q:My Backup Folder”
To copy only changed .doc files, use
XCOPY “D:Projects*.doc” “Q:My Backup Folder”
To copy files changed since 11/28/2006, use
XCOPY “D:Projects*.” “Q:My Backup Folder” /d:11-28-2006
To see a list of files that would be copied if you ran this command,
XCOPY “D:Projects*.” “Q:My Backup Folder” /s /i /f /y /d /l
The slash commands at the end of the line are options. You can craft precise commands.
COPY and DEL
The main advantage of the DOS Copy or Delete command is that you can specify which files to copy or delete by using file name wildcards. The slight advantage is that you don’t have to manually click on each file as you would if you had a long list of files or used the Windows Find command first. For example, to copy only the Word files, use
Or combine types. To copy or delete Word and Excel files, use
Del *.doc *.xls
This directory command lists files in a directory, but it gives you much more control over the display. Used by itself, it lists all the files and folders in the directory:
Or to specify the names, use
Use wildcards in the name. The first command lists only Word documents, and the second one matches any letter for the ? symbol
Most of these options are presented in the Windows search dialog box, but curiously, even in the twenty-first century, Windows still does not have a way to print files in a folder. The easiest way to do this to save it to a file first:
Dir > filelisting.txt
And then print that file. As in most DOS commands, you can use wildcards:
Dir *.doc > filelisting.txt
If you want a list of only the file names and not the directory path, file size, or everything else included in the default command, use
Dir *.doc /b > filelisting.txt
One important feature not easily replicated in Windows is the use of batch files. Once a mainstay for PC operations, batch files let you store DOS commands in a single location and run them all at one time. In practice, using batch files is the equivalent of typing a series of DOS commands from the command line. For example, if you wanted to use XCOPY to back up files to a safe location and then delete all the files, you use the following commands:
xcopy “D:Projects*.” “Q:My_Backup_Folder” /s /i /f /y /d >>”d:backup_log.txt”
Obviously, that is too much typing to do each time you want to perform those functions. So insert those commands as plain text in NotePad and save the file with a .bat extention. To run the file, just enter that file name in the command line. You can create complex scripts and even include basic logic instructions such as IF statements and looping. Although so much more is possible with current scripting technologies (such as using macros in Microsoft Office), those technologies are often seen as difficult and may require formal programming support. Batch files, in comparison, may not be as versatile but are easy to implement and may meet many team needs.
Other Useful DOS Commands (Place this section in sidebar?)
The following commands are also useful.
Comp: Compares contents of two files or sets of files. This is most useful if the two files are supposed to be identical or have minor differences.
Fc: Compares two files or sets of files. Displays the differences between files in a text format.
find: Searches for a text string in a file or files. More versatile than Windows Search.
findstr: Searches for a regular expression text string in a file or files. A very powerful string find. Uses regular expressions to find text. This pattern matching can find hyperlinks and part numbers, for example. No Windows tool does exactly the same thing.
tree: Displays the folder structure visually. Sometimes you want to show the structure of a folder, including each subfolder. There is no matching tool in Windows.
move or copy: Moves or copies files from one location to another. This is more flexible than copy and paste because you can specify the files or wildcards.