MS-DOS [Working With Files] Part 7

Renaming a File
To rename a file, use the rename (ren) command, as in the following example:
ren mytax.dat ourtax.dat

To change the name of a file without changing its location, use the rename command. This command is especially helpful for organizing files. For example, suppose you have two versions of a file named PRICES.LST. The version on the disk in drive A contains last year's prices, whereas the version on drive C is current. To avoid confusion between the two files, you can use the following command to rename the file that contains outdated prices:

ren a:prices.lst prices.old

You can use wildcards to rename a group of files. For example, if you want all .TMP files to be renamed to .TXT files in a directory, use the following command.

ren *.tmp *.txt

Shell  To rename files:
1. From the file list, select the file or files you want to rename.
2. From the file menu, choose Rename. The Rename File dialog box lists the current name of the first selected file.
3. In the New Name box, type the new filename.
4. Choose the OK button.
If you select more than one file, the Rename File dialog box prompts you to rename each file separately.

Printing Text Files

You can print unformatted text files from MS-DOS by using the print command. Generally, it is best to print formatted text files and other specialized files from the program you used to create them. For information about specialized data files and unformatted text files, see "Types of Files" earlier in this chapter.

MS-DOS has print options that another program may lack. With MS-DOS, you can start a print job and do other tasks while the printer prints. In addition, you can specify a list of files to print so you don't have to print each file separately.

When you use the print command, a print queue is set up. Before printing, make sure your printer is properly connected to your system, that the power is turned on, and that the printer is online. For information about your printer, see your printer documentation.

Printing Files

To print unformatted text file from MS-DOS, use the print command, as in the following example:

print config.sys

MS-DOS prompts you for the port you want to print to. If you don't specify a port, MS-DOS connects to LPT1 (also called PRN).
You can set the default printer port by using the /d switch the first time you use the print command. For example, if your printer is connected to your COM1 port, use the following command:
print /d:com1

Suppose you want to print a file named TOGO.TXT. Type the following command:
print togo.txt
The first time you use the print command, MS-DOS prompts you for the port to print to. Whenever you use the print command again. MS-DOS uses the port you specified the first time. To change the port setting, you must restart your system and use the print command again.
You can set the default printer port by using the /d  switch, as in the following example:
print /d:com1 togo.txt
The /d switch can only be used the first time you use the print command. Always use a colon (:) to separate the /d switch from the port name.
To print more than one file at a time, you can type the various filenames and use spaces to separate them, or you can use wildcards.
Shell  To print files:
1. Before using MS-DOS Shell, type print at the command prompt. You can add the print command to your AUTOEXEC.BAT file to avoidhaving to type it each time you run MS-DOS Shell. The print command must precede the dosshell command in the AUTOEXEC.BAT file.
2. From the file list, select one or more files.
3. From the File menu, choose Print.MS-DOS adds the files to the print queue (the list of files waiting to be printed).

Using the Print Queue

To view the contents of the print queue, use the print command:

print
To cancel printing and empty the print queue, use the /t switch:
print /t

The MS-DOS print queue is a list of files waiting to be printed. The file at the top of the queue is the one currently being printed. MS-DOS adds your files the print queue when you use the print command. After the first file is printed, MS-DOS begins printing the second file.
To see the list of files in the print queue, type the following:
print
MS-DOS list of files in the queue and indicates which one is currently printing.
To cancel printing and empty the print queue, use the /t switch:
print /t
MS-DOS stop sending information to your printer. The printer keeps printing until it prints all the information stored in its memory.

NOTE  The print queue requires memory that MS-DOS and your programs could otherwise use. Therefore, using the print queue may affect the efficiency of your system

Deleting Files

As you work with MS-DOS, you may want to remove files that are no longer useful. You can delete a single file, selected groups of files in a directory or on a disk. Once you delete files, you might not be able to recover them. Be sure that the files you specify for deletion are the ones you want to remove.
If you accidentally delete files you wanted to keep, use the undelete command as soon as possible to recover them. The undelete command might not be able to recover the deleted files if you created or changed other files on the disk in the mean time. The undelete command works best if you set up your system to keep track of files you delete.

Tracking Deleted Files

If you want MS-DOS to keep track of deleted files on a disk, you can use the Mirror program. To install the program, use the mirror command with the /t switch. For example, the following command sets up deletion tracking for a disk in drive A:
mirror /ta
The drive letter must follow the /t switch. However, do not use a colon ( : ) with the drive letter.

The Mirror program is a 6.4K terminate-and-stay-resident (TSR) program that monitors the system. Whenever the program detects a deleted file, it record information that the undelete command needs to recover the file. To install this program, use the mirror command with /t switch for each drive you want to track. For example, to install the program so that it tracks file deletions on drive A and C, you would type the following:
mirror /ta /tc
The first time you delete a file on drive A or C after you have installed Mirror, a file called PCTRACKR.DEL is created in the root directory of that drive. This is a system file that contains the information which undelete needs to recover the deleted file. Each time you delete a file, PCTRACKR.DEL is updated with information about that file.

CAUTION  Do not use deletion tracking for any drive that has been redirected by using the join or subst command. If you intend to use the assign  command, you must do so before using Mirror to install deletion tracking.

[Previous]      [Read Next Chapter]
    

Continued...


Keyword: Learning MS-DOS | The Complete MS-DOS Commands | MS-DOS tutorial | MS-DOS Script

You may also like: