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

by admin on August 15, 2010

We can use ‘attrib’ command to set/unset file attributes. Let us see how to use this command to manipulate different file attributes from windows command line(CMD). Take a sample file example.doc

To set archive attribute for the file example.doc:

attrib +a example.doc

To unset archive attribute:

attrib -a example.doc

To set read only attribute:

attrib +r example.doc

To unset read only attribute:

attrib -r example.doc

To make the file hidden :

attrib +h example.doc

To remove the hidden attribute:

attrib -h example.doc

To set system file attribute:

attrib +s example.doc

To unset system file attribute:

attrib -s example.doc

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

Relevant links:

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

{ 7 comments… read them below or add one }

Ricky January 22, 2011 at 9:19 am

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…………

Reply

Techblogger January 22, 2011 at 10:13 am

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..

Reply

Techblogger January 22, 2011 at 10:16 am

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

Reply

Anonymous March 22, 2011 at 3:08 pm

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..

Reply

Lalit kirar August 15, 2011 at 5:21 am

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

Reply

admin August 15, 2011 at 4:07 pm

Which Windows release and edition you are using?

not Lalit kirar December 24, 2013 at 8:21 am

i think you should remove your C:\

Leave a Comment

HTML tags are not allowed.

Previous post:

Next post: