Share on Facebook Share on Twitter Email
Answers.com

Attrib

 
 

An external command that displays and changes file attributes, which are settings in every DOS file. The file attributes are bits that are turned on (set to 1) or turned off (set to 0).

             FILE ATTRIBUTES

             A - Archive
             H - Hidden file
             R - Read only
             S - System file

To display the current attributes in all files in the current directory, type:

      attrib *.*     files only
      attrib *.* /s  files & subdirectories

READ ONLY STATUS

When a file is read-only, it cannot be changed or deleted. To set and reset VITAL.TXT, type:

   attrib vital.txt +r   set to read-only
   attrib vital.txt -r   reset to read/write

ARCHIVE ATTRIBUTE

As of DOS 3.3, all files are set to archive status (archive bit on), which assists in making backups. When files are copied by the Xcopy or Backup commands, the archive bit is turned off (0) on the original file and not turned on again (1) until the file has been modified by some application. The following example removes and restores the archive status in XYZ.TXT.

   attrib xyz.txt -a   turn off
   attrib xyz.txt +a   turn back on

To back up only modified files (archive bit on), use the /m switch with the Xcopy and Backup commands. After copying, the archive bit on the original file is turned off (set to zero). For example, to Xcopy only modified files (archive bit on) to the B drive, type:

           xcopy *.* b: /m

For more archive examples, see DOS Xcopy and DOS Backup/Restore.

SYSTEM AND HIDDEN ATTRIBUTE (as of DOS 5)

These attributes are assigned to important DOS files and other files that your applications may generate. As a rule, you should not tamper with them unless you know what you are doing. Prior to DOS 5, you needed a third-party utility to do this. As of DOS 5, you can reset these attributes in most, but not all files, in which case you may still need a third-party program.

   attrib xyz +s   make XYZ a system file
   attrib xyz -s   clear system file status

   attrib xyz +h   make XYZ a hidden file
   attrib xyz -h   clear hidden status

Download Computer Desktop Encyclopedia to your iPhone/iTouch

Search unanswered questions...
Enter a word or phrase...
All Community Q&A Reference topics
Wikipedia: Attrib
 

attrib is a command, in MS-DOS, OS/2 and Microsoft Windows. The function of attrib is to set and remove file attributes (read-only, archive, system and hidden). These attributes are used by a wide variety software to protect and classify files.[1]

Many users regularly encounter the read-only attribute, which will prevent most software from allowing the user to overwrite or append to a file. Software can be designed to override this option, often after receiving confirmation from the user. The archive attribute is used by various backup and file copy programs as a hint as to whether a file needs to be backed up.[2] The hidden attribute makes affected files invisible in many programs, although a variety of software, especially software designed for listing, viewing, and searching files, allows hidden files to be made visible, often with a notation that they have been designated as hidden. The system attribute is used to designate certain operating system files and affects the operation of most software less than the other attributes.

Contents

Particularities

In certain versions, when both the s and h attributes are set, they can only be removed at the same time. To remove only one, they must both be removed at the same time, and then the desired attribute must be set.

ie. C:> attrib -S -H *.*

The command will not clear the Read-Only flag from Hidden files and will report that the flag was not cleared on each file.

Use in defragmentation

Copying files from read-only media such as a CD or DVD backup will preserve the read-only flag on the files. There is no need for this flag on your read/write drive. Read-only files will interfere with the effectiveness of defragmentation in two ways:

  1. Larger files may have been copied to your drive in fragments. These fragments will not be able to be reunited and will remain fragmented.
  2. Smaller files will not be able to be moved to the best location and may prevent the assembling of contiguous free space needed for large files.

Thus when you want to defragment your drive you need to clear the Read-Only flag on all files. From dos in the root directory issue the following command;

C:> attrib -R *.* /S /D

Hidden files will not be made read/write by this command. An example of a hidden file is the thumbnail index in picture directories. You will be notified of hidden files when running the above command. You may run this command to set the hidden files to read/write;

C:> attrib -H -R *.* /S /D

Differences between Windows versions

The "/D" switch (which recurses into sub-directories) was introduced with Windows XP and Windows Server 2003, and "/L" (which instructs attrib to work with the attributes of the symbolic link itself instead of the target of the symbolic link) was introduced with Windows Vista and Windows Server 2008.

Undocumented features

If a comma is typed directly after the command's name (for example, attrib, *.txt), all attributes will be removed from the targeted files (in this case, all .txt files in the folder). In most versions, if a target isn't specified, then all attributes will be removed from the folder currently being browsed in DOS.

References

  1. ^ Yabumoto, Kan (2000-01-17). "XXCOPY Technical Bulletin #06". http://www.xxcopy.com/xxcopy06.htm. Retrieved on 2007-08-02. 
  2. ^ "DOS Attrib". Encyclopedia. PC Magazine. http://www.pcmag.com/encyclopedia_term/0,2542,t=DOS+Attrib&i=41730,00.asp. Retrieved on 2007-08-02. 

See also


 
 

 

Copyrights:

Computer Desktop Encyclopedia. THIS COPYRIGHTED DEFINITION IS FOR PERSONAL USE ONLY.
All other reproduction is strictly prohibited without permission from the publisher.
© 1981-2009 Computer Language Company Inc.  All rights reserved.  Read more
Wikipedia. This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Attrib" Read more