You are on page 1of 3

ATTRIB.

exe
Displayorchangefileattributes.FindFilenames.
Syntax
ATTRIB[+attribute|attribute][pathname][/S[/D]]
Key
+:TurnanattributeON
:ClearanattributeOFF
pathname:Driveand/orfilenamee.g.C:\*.txt
/S:Searchthepathnameincludingallsubfolders.
/D:Processfoldersaswell
attributes:
RReadonly(1)
AArchive(32)
SSystem(4)
HHidden(2)
extendedattributes:
EEncrypted
CCompressed(128:readonly)
INotcontentindexed
LSymboliclink/Junction(64:readonly)
NNormal(0:cannotbeusedforfileselection)
OOffline
PSparsefile
TTemporary
XNoscrubfileattribute(Windows8+)
VIntegrityattribute(Windows8+)
ThenumericvaluescanbeusedwhenchangingattributeswithVBS/WSH
Ifnoattributeisspecifiedattribwillreturnthecurrentattributesettings.Usedwithjustthe/S
optionATTRIBwillquicklysearchforaparticularfilename.
HiddenandSystemattributestakepriority.
IfafilehasboththeHiddenandSystemattributesset,youcanclearbothattributesonlywith
asingleATTRIBcommand.
Forexample,tocleartheHiddenandSystemattributesfortheRECORD.TXTfile,youwould
type:
ATTRIBSHRECORD.TXT
FileAttributes
Youcanusewildcards(?and*)withthefilenameparametertodisplayorchangethe
attributesforagroupoffiles.
Rememberthat,ifafilehastheSystemorHiddenattributeset,youmustclearthatattribute
beforeyoucanchangeanyotherattributes.

DirectoryAttributes
Youcandisplayorchangetheattributesforadirectory/folder.TouseATTRIBwitha
directory,youmustexplicitlyspecifythedirectorynameyoucannotusewildcardstowork
withdirectories.
Forexample,tohidethedirectoryC:\SECRET,youwouldtypethefollowing:
ATTRIB+HC:\SECRET
Thefollowingcommandwouldaffectonlyfiles,notdirectories:ATTRIB+HC:*.*
TheReadonlyattributeforafolderisgenerallyignoredbyapplications,howevertheRead
onlyandSystemattributesareusedbyWindowsExplorertodeterminewhetherthefolderis
aspecialfolder,suchasMyDocuments,Favorites,Fonts,etc.
SettingtheReadOnlyattributeonafoldercanaffectperformance,particularlyonshared
drivesbecauseWindowsExplorerwillbeforcedtorequesttheDesktop.iniofeverysub
foldertoseeifanyspecialfoldersettingsneedtobeset.
Viewingarchiveattributes
TheArchiveattribute(A)isusedtomarkfilesthathavechangedsincetheywerepreviously
backedup.The(A)flagisautomaticallyupdatedbyWindowsasthefileissaved.
Ifthe(A)flagispresentthefileisneworhasbeenchangedsincethelastbackup.
TheMSBACKUP,RESTORE,andXCOPYcommandsusetheseArchiveattributes,asdo
many(butnotall)3rdpartybackupsolutions.
ExtendedAttributes
Fileattributescanbereadwithfsutilusnreaddatafilename.ext
ConstantsthefollowingattributevaluesarereturnedbytheGetFileAttributesfunction:
FILE_ATTRIBUTE_READONLY=1(0x1)
FILE_ATTRIBUTE_HIDDEN=2(0x2)
FILE_ATTRIBUTE_SYSTEM=4(0x4)
FILE_ATTRIBUTE_DIRECTORY=16(0x10)
FILE_ATTRIBUTE_ARCHIVE=32(0x20)
FILE_ATTRIBUTE_NORMAL=128(0x80)
FILE_ATTRIBUTE_TEMPORARY=256(0x100)
FILE_ATTRIBUTE_SPARSE_FILE=512(0x200)
FILE_ATTRIBUTE_REPARSE_POINT=1024(0x400)
FILE_ATTRIBUTE_COMPRESSED=2048(0x800)
FILE_ATTRIBUTE_OFFLINE=4096(0x1000)
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED=8192(0x2000)
FILE_ATTRIBUTE_ENCRYPTED=16384(0x4000)
Forexample,afileattributeof0x120indicatestheTemporary+Archiveattributesareset
(0x100+0x20=0x120.)
AnalternativeisusingFORparameterattributes

DFSRwillnotreplicatefilesiftheyhavethetemporaryattributeset.
ThetemporaryattributecanberemovedbyusingPowerShelltosubtract0x100:
PSC:\>GetchilditemD:\Datarecurse|ForEachObjectprocess{if
(($_.attributesband0x100)eq0x100){$_.attributes=
($_.attributesband0xFEFF)}}
Themoralsenseofconscienceisbyfarthemostimportant..itisthemostnobleofall
thea ributesofmanCharlesDarwin

You might also like