Classic Computer Magazine Archive COMPUTE! ISSUE 145 / OCTOBER 1992 / PAGE 50

Your files' best attributes. (DOS 5.0 command)
by Tony Roberts

Each of us has attributes. My wife has gray eyes; my daughter has blond hair; I have no hair. Each of the files on our computer systems has attributes, too. These attributes tell us something about the properties of the file.

Files can be marked as system, hidden, read-only, or archive. Although you shouldn't be concerned with these attributes on a daily basis, they come in handy when you need to change a file's properties.

The ATTRIB command in DOS 5.0 permits you to view and change any of a file's attributes. Earlier versions allowed access to the archive and read-only attributes but kept the system and hidden attributes under wraps.

Move to the root directory and enter ATTRIB at the DOS prompt. You'll see a list of files and their attributes. Included in the list will be the DOS system files, which are marked SHR--system, hidden, and read-only. This is how DOS protects these crucial files. To delete them, you'd need to turn off the hidden attribute, turn off the system attribute, and turn off the read-only attribute. This is hardly something you could do by accident.

Most of the other files will either have no attributes set or will be marked A, signifying that the archive attribute has been set. This usually indicates that the file has been changed since the system was last backed up,

Of all the attribute settings, the archive attribute is certainly the most useful to the average computer user. Read-only can be of some value if you have reference documents that you don't want changed.

The system and hidden attributes are generally best left to the system to control, but occasionally it helps to be able to change those attributes. Some software, for example, makes use of system or hidden files to store default information, scores, or other data it doesn't want anyone tampering with. If you decide not to use the software, you delete all the files and remove the subdirectory.

But sometimes the subdirectory just refuses to be removed. You get messages insisting that the directory isn't empty, even though you're certain that it is. Move to the offending subdirectory and enter ATTRIB. Chances are you'll see that there are hidden files lurking there. Now use the ATTRIB command again to reveal the files.

For example, if the hidden file was named PROGRAM.DAT, then the command ATTRIB-H PROGRAM.DAT would reveal it. Now you should be able to delete the file and remove the subdirectory.

This example illustrates how to remove attributes from any file. Type ATTRIB, then a minus sign and a letter indicating the attribute to be removed, and then the filename. Adding attributes to files follows a similar process, but a plus sign is used in place of the minus sign.

If you have several files to work on, DOS 5.0's ATTRIB command works with wildcards, too. ATTRIB +A *.DOC would turn on the archive attribute for all the DOC files in the current subdirectory. lf you append /S to the above command, ATTRIB will do its work in the current directory and any subdirectories within it.

The archive attribute comes into play when you back up your hard disk. The DOS backup command, and most other commercial backup software, turns off the archive attribute once a file has been backed up. The next time you run your backup software, you can elect to back up only those files that have changed--as indicated by the archive attribute.

I normally don't back up application files as part of my regular backups. After all, I have the original disks if the software ever needs reinstallation. I do, however, want to back up all of the files that are created or changed after the installation.

As soon as I install a new application, I move to the directory where the installation took place and issue the command ATTRIB-A *.* Is to turn off the archive attribute for all of the new files. This prevents acres of printer drivers and help files from being needlessly copied to my backup disks.

The archive attribute also can be used in conjunction with XCOPY. If you use the/A switch with XCOPY, the program will copy only those files whose archive attribute is set. If you use the IM switch with XCOPY, the program copies only those files whose archive attribute is set and then, once the copy is complete, turns off the archive attribute for files successfully copied.

You can make use of this ATTRIB/XCOPY combination to copy several files to floppy disks, even when you know the files won't all fit on one floppy disk. Let's say you wanted to copy all of your spreadsheet files to floppy. First, turn on the archive attribute for the files with a command such as ATTRIB +A *.WKl. Then use XCOPY *.WK1 A: IM to copy the files to the disk in drive A. When the disk is full, XCOPY will stop. Simply insert another disk and reissue the same command. The archive attribute for the files that made it successfully to the first disk will be turned off, so those files won't be copied again. Continue the process until all the specified files have been copied.