Displays or changes file attributes.
This command displays, sets, or removes the Read-Only, Archive, System, and Hidden attributes assigned to files or directories.
ATTRIB [+A | -A] [+H | -H] [+R | -R] [+S | -S] [[drive:][path]filename] [/S [/D]]
Display all attributes of all files in the current directory:
XCOPY - copying files and directories with different attributes.
If a file has both the Hidden and System attributes set, you can clear both attributes only with a single ATTRIB command. For example, to clear the Hidden and System attributes for the RECORD.TXT file, you would type:
ATTRIB -S -H RECORD.TXT
You can use wildcards (? and *) with the filename parameter to display or change the attributes for a group of files. If a file has the System or Hidden attribute set, you must clear that attribute before you can change any other attributes for that file.
You can display or change the attributes for a directory. To use ATTRIB with a directory, you must explicitly specify the directory name; you cannot use wildcards to work with directories. For example, to hide the directory C:\SECRET, you would type:
ATTRIB +H C:\SECRET>
Affects only files, not directories:
ATTRIB +H C:*.*
The Archive attribute (A) is used to mark files that have changed since they were previously backed up. The BACKUP, RESTORE, and XCOPY commands use these Archive attributes.
UNDOCUMENTED Removes attributes of all files in the current subdirectory:
this is the same as:
ATTRIB -A -H -R -S *.*
To display the attributes of a file named NEWS86 located on the current drive, type:
To assign the Read-Only attribute to the file REPORT.TXT, type:
ATTRIB +R REPORT.TXT
To remove the Read-Only attribute from files in the \PUBLIC\JONES directory on a disk in drive B and from files in any subdirectories of \PUBLIC\JONES, type:
ATTRIB -R B:\PUBLIC\JONES\*.* /S
As a final example, suppose you want to give an associate a disk containing all files in the default directory on a disk in drive A except files with the .BAK extension. Because you can use XCOPY to copy only those files marked with the Archive attribute, you need to set the Archive attribute for those files you want to copy. To do this, you would use two commands to set the Archive attribute for all files on drive A and then to clear the attribute for those files with the .BAK extension:
ATTRIB +A A:*.* ATTRIB -A A:*.BAK
Next, use the XCOPY command to copy the files from the disk in drive A to the disk in drive B. The /A switch causes XCOPY to copy only those files marked with the Archive attribute:
XCOPY A: B: /A
If you want XCOPY to clear each file's Archive attribute after it copies the file, use the /M switch instead of /A:
XCOPY A: B: /M