Monday, March 9, 2009

Set hidden folder or file using attrib command

To view the hidden folder
CMD: dir /a (/a mean show attrib file)

attrib
Syntax
ATTRIB [ + attribute | - attribute ] [pathname] [/S [/D]]

Key
+ : Turn an attribute ON
- : Clear an attribute OFF

/S : Search the pathname including all subfolders.
/D : Process folders as well

attributes:

R Read-only (1)
H Hidden (2)
A Archive (32)
S System (4)

extended attributes:
E Encrypted
C Compressed (128:read-only)
I Not content-indexed
L Symbolic link/Junction (64:read-only)
N Normal (0: cannot be used for file selection)
O Offline
P Sparse file
T Temporary

Example:
1. To hide the file
attrib +h abc.txt

2. To hide the folder
attrib /D +h abcfolder

3. To unhide the file
attrib -h abc.txt

4. To unhide the folder
attrib /D -h abcfolder

5. To view the attrib attribute
attrib

6. To set include the subfolder as well
attrib /S /D +h *