attrib

显示、设置或删除分配给文件或目录的属性。 If used without parameters, attrib displays attributes of all files in the current directory.

Syntax

attrib [{+|-}r] [{+|-}a] [{+|-}s] [{+|-}h] [{+|-}o] [{+|-}i] [{+|-}x] [{+|-}p] [{+|-}u] [{+|-}b] [<drive>:][<path>][<filename>] [/s [/d] [/l]]

Parameters

Parameter Description
{+\|-}r 设置 (+) 或清除 (-) 只读文件属性。
{+\|-}a 设置 (+) 或清除 (-) 存档文件属性。 此属性集标记自上次备份以来已更改的文件。 The xcopy command uses archive attributes.
{+\|-}s 设置 (+) 或清除系统-文件属性。 如果文件使用此属性集,则必须清除该属性,然后才能更改文件的任何其他属性。
{+\|-}h 设置 (+) 或清除 (-) 隐藏文件属性。 如果文件使用此属性集,则必须清除该属性,然后才能更改文件的任何其他属性。
{+\|-}o 设置 (+) 或清除 (-) 脱机文件属性。
{+\|-}i 设置 (+) 或清除 (-) 非内容索引文件属性。
{+\|-}x 设置 (+) 或清除 (-) 清理文件属性。
{+\|-}p 设置 (+) 或清除固定-文件属性。
{+\|-}u 设置 (+) 或清除 (-) 未固定的文件属性。
{+\|-}b 设置 (+) 或清除 (-) SMR Blob 文件属性。
[<drive>:][<path>][<filename>] 指定要查看或更改属性的目录、文件或文件组的位置和名称。
You can use the ? and * wildcard characters in the filename parameter to display or change the attributes for a group of files.
/s Applies attrib and any command-line options to matching files in the current directory and all of its subdirectories.
/d Applies attrib and any command-line options to directories.
/l Applies attrib and any command-line options to the Symbolic Link, rather than the target of the Symbolic Link.
/? 在命令提示符下显示帮助。

Examples

若要显示位于当前目录中的名为 News86 的文件的属性,请键入:

attrib news86

若要将只读属性分配给名为 report.txt的文件,请键入:

attrib +r report.txt

若要从公共目录中的文件及其驱动器 b:中的磁盘上的子目录中删除只读属性,请键入:

attrib -r b:\public\*.* /s

若要为驱动器 a:上的所有文件设置 Archive 属性,然后清除具有.bak扩展名的文件的 Archive 属性,请键入:

attrib +a a:*.* & attrib -a a:*.bak