Purpose:Change or view file and subdirectory attributes


Format:ATTRIB [/= /A:[[-+]rhsa] /D /E /I"text" /L /N[EJ] /O:[-]acdeginorstuz /P[n] /Q /S[[+]n]] [+|-[AHIOPRSTUVX]] [@file] files ...


filesA file, directory, or list of files or directories to process.
@fileA text file containing the names of the files to process, one per line (see @file lists for details).


/A: (Attribute select)




/E (No error messages)


/I"text" (match description)


/L (symbolic Link)



Attribute flags:



Attribute affected












not content indexed






pinned (Windows 10+ and OneDrive only)












unpinned (Windows 10+ and OneDrive only)



integrity (Windows Server 2012R2+ ReFS only)



no_scrub_data (Windows Server 2012R2+ ReFS only)


File Selection


Supports command dialog, attribute switches, extended wildcards, ranges, multiple file names, and include lists. Use wildcards with caution on LFN volumes; see LFN File Searches for details.




Every file and subdirectory has attributes that can be turned on (set) or turned off (cleared): Archive, Hidden, Not content indexed, Offline, Read-only, System, and Temporary. For details on the meaning of each attribute, see File Attributes.


The ATTRIB command lets you view, set, or clear attributes for any file, group of files, or subdirectory.


You can view file attributes by entering ATTRIB without specifying new attributes (i.e., without the [+|-[AHIOPRSTUVX]] part of the format), or with the DIR /T command.


The primary use of ATTRIB is to set attributes. For example, you can set the read-only and hidden attributes for the file MEMO:


attrib +rh memo


Attribute options apply to the file(s) that follow the options on the ATTRIB command line. The example below shows how to set different attributes on different files with a single command. It sets the archive attribute for all .TXT files, then sets the system attribute and clears the archive attribute for TEST.EXE:


attrib +a *.txt +s -a test.exe


When you use ATTRIB on an LFN drive, you must double quote any file names which contain white space or special characters.


To change directory attributes, use the /D switch. If you give ATTRIB a directory name instead of a file name, and omit /D, it will append "\*" to the end of the name and act on all files in that directory, rather than acting on the directory itself.


NTFS also supports D (subdirectory), V (virtualized), E (encrypted), J or L (junction / symbolic link) and P (sparse file) attributes. These attributes will be displayed by ATTRIB, but cannot be altered; they are designed to be controlled only by Windows.


ATTRIB will ignore underlines in the new attribute (the [+|-[ADHIOPRSTUVX]] part of the command). For example, ATTRIB sees these 2 commands as identical:


attrib +a filename

attrib +__A_ filename


This allows you to use a string of attributes from either the @ATTRIB variable function or from ATTRIB itself (both of which use underscores to represent attributes that are not set) and send that string back to ATTRIB to set attributes for other files. For example, to clear the attributes of FILE2 and then set its attributes to match those of FILE1:


attrib -arhs file2 & attrib +%@attrib[file1] file2


When ATTRIB encounters a +D or -D in the attribute string it treats it as equivalent to the /D switch, and allows modification of the attributes of a directory. When combined with @ATTRIB, or with ATTRIB's output, both of which return a D to signify a directory, this feature allows you to transfer attributes from one directory to another. For example, to clear the attributes of all files and directories beginning with ABC and then set their attributes to match those of FILE1 (enter this on one line):


attrib -arhs abc* & attrib +%@attrib[file1] abc*


ATTRIB sets three internal variables:


%_attrib_dirsThe number of directories modified
%_attrib_filesThe number of files modified
%_attrib_errorsThe number of errors




/=Display the ATTRIB command dialog to help you set the filename and command line options. The /= option can be anywhere on the line; additional options will set the appropriate fields in the command dialog.


/A:Select only those files that have the specified attribute(s) set. See Attribute Switches for information on the attributes which can follow /A:. Warning: the colon after /A is not optional.


This switch specifies which files to select, not which attributes to set. For example, to remove the archive attribute from all hidden files, you could use this command:


attrib /a:h -a *


Do not use /A: with @file lists. See @file lists for details.


You can specify /A:= to display a dialog to help you set individual attributes.


/DIf you use the /D option, ATTRIB will modify the attributes of directories in addition to files (yes, you can have a hidden directory):


attrib /d +h c:\mydir


If you use a directory name instead of a file name, and omit /D, ATTRIB will append "\*" to the end of the name and act on all files in that directory, rather than acting on the directory itself.


/ESuppress all non-fatal error messages, such as "File Not Found."  Fatal error messages, such as "Drive not ready," will still be displayed. This option is most useful in batch files and aliases, and when recursing through the directory hierarchy, where many directories have no files matching your selection criteria.        .


/I"text"Select files by matching text in their descriptions. The text can include wildcards and extended wildcards. The search text must be enclosed in double quotes, and must immediately follow the /I, with no intervening spaces. You can select all filenames that have a description with /I"[?]*", or all filenames that do not have a description with /I"[]". Do not use /I with @file lists. See @file lists for details.


/LSet or display the attributes of the symbolic link versus the target of the symbolic link.


/NDo everything except actually change the attributes. This option is useful for testing what the result of a complex ATTRIB command will be.


A /N with one of the following arguments has an alternate meaning:


e        Don't display errors.

j        Skip junctions (when used with /S)


/O:...Sort the files before processing.


You may use any combination of the sorting options below. If multiple options are used, the listing will be sorted with the first sort option as the primary key, the next as the secondary key, and so on:


nSort by filename and extension, unless e is explicitly included.
-Reverse the sort order for the next sort key
aSort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension.
cSort by compression ratio
dSort by date and time (oldest first); also see /T:acw
eSort by extension
gGroup subdirectories first, then files
iSort by description
oSort by owner
rReverse the sort order for all options
sSort by size
tSame as d
zSame as s


/P[n]Wait for a key to be pressed after each screen page before continuing the display. Your options at the prompt are explained in detail under Page and File Prompts. The /P option has an optional argument n that specifies the number of seconds to wait for a keystroke before continuing.


/QThis option turns off ATTRIB's normal screen output. It is most useful in batch files.


/SIf you use the /S option, the ATTRIB command will be applied to all matching files in the current or named directory and all of its subdirectories. Do not use /S with @file lists; see @file lists for details.


If you specify a number after the /S, ATTRIB will limit the subdirectory recursion to that number. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only affect the "a", "b", and "c" directories.


If you specify a + followed by a number after the /S, ATTRIB will not modify any file attributes until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not modify anything in \a or \a\b.