≡ Menu

Attrib command : Set file attributes from command line (CMD)

Attrib command can be used to set or unset file attributes from Windows command prompt. This post explains with examples the syntax for managing the file attributes on Windows computer.

Archive attribute

To set archive attribute for the file example.doc:

attrib +a example.doc

To unset archive attribute:

attrib -a example.doc

Read-only attribute

To set read only attribute:

attrib +r example.doc

To unset read only attribute:

attrib -r example.doc

Hidden attribute

To make the file hidden :

attrib +h example.doc

To remove the hidden attribute:

attrib -h example.doc

System attribute

To set system file attribute:

attrib +s example.doc

To unset system file attribute:

attrib -s example.doc

Attrib command works on all Windows editions(XP, Vista, Windows 7, Windows 10, Server 2K3 & 2K8)

Set file attributes in bulk

Attrib command accepts wild characters and can process files in bulk. The syntax for bulk processing is given below

attrib +[R/H/S/A]  *

To set attribute for files of certain type/extension

attrib +[R/H/S/A] *.ext

To set attribute for all files in current directory

attrib +[R/H/S/A]

Example:
Set hidden attribute on all PDF files in the current directory

attrib +H *.pdf

Relevant links:

Attrib command: Not resetting hidden file
Attrib command: Not resetting system file

8 comments… add one
  • Ricky

    i have used "ATTRIB" command two month before and i have hidden some kind of files … but now i forgot the file name … may i know how to get my file name "ATTRIB". i know how to unset for "ATTRIB".. but just forgaot my file name.. please any one help me how to get file name from "ATTRIB" command…………

  • Techblogger

    Ricky,
    You can get the file name in two ways..open the directory in explorer window and enable 'show hidden files and folders' in Tools->Folder options->View. After this you should be able to see all the hidden files in that folder…

    The other way is through command line. cd to the folder where you have the hidden files and press Tab key. You will see the name of the file that comes first in alphabetical order.. keep on pressing Tab key until you get the hidden file you created..

  • Techblogger

    And one more simple way is to run the command 'attrib -h * '. this will remove hidden flag for all the files in that directory..

  • Anonymous

    i dont know how to use this 'atrib -h*t'

    but this option works good…. thanks

    'cd to the folder where you have the hidden files and press Tab key. You will see the name of the file that comes first in alphabetical order.. keep on pressing Tab key until you get the hidden file you created..

  • Lalit kirar

    my command prompt doesn’t support the attrib command …
    what should i do now.
    thanks

    • admin

      Which Windows release and edition you are using?

    • not Lalit kirar

      i think you should remove your C:\

  • jherimy

    what command i can used to return the file of my flush-drive? thnks

Leave a Comment