# FileSetAttrib

Changes the attributes of one or more files or folders. Wildcards are supported.

FileSetAttrib, Attributes [, FilePattern, OperateOnFolders?, Recurse?]

#### Parameters

Attributes | The attributes to change (see Remarks).
FilePattern | The name of a single file or folder, or a wildcard pattern such as C:\Temp\*.tmp. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified. If omitted, the current file of the innermost enclosing File-Loop will be used instead.
OperateOnFolders? | 0 (default) Folders are not operated upon (only files). 1 All files and folders that match the wildcard pattern are operated upon. 2 Only folders are operated upon (no files). Note: If FilePattern is a single folder rather than a wildcard pattern, it will always be operated upon regardless of this setting. This parameter can be an expression.
Recurse? | 0 (default) Subfolders are not recursed into. 1 Subfolders are recursed into so that files and folders contained therein are operated upon if they match FilePattern. All subfolders will be recursed into, not just those whose names match FilePattern. However, files and folders with a complete path name longer than 259 characters are skipped over as though they do not exist. Such files are rare because normally, the operating system does not allow their creation. This parameter can be an expression.

#### ErrorLevel

ErrorLevel is set to the number of files that failed to be changed or 0 otherwise.

#### Remarks

The Attributes parameter consists of a collection of operators and attribute letters.

Operators:

+ | Turn on the attribute
- | Turn off the attribute
^ | Toggle the attribute (set it to the opposite value of what it is now)

Attribute letters:
R = READONLY
A = ARCHIVE
S = SYSTEM
H = HIDDEN
N = NORMAL (this is valid only when used without any other attributes)
O = OFFLINE
T = TEMPORARY

Note: Currently, the compression state of files cannot be changed with this command.

#### Related

FileGetAttrib, FileGetTime, FileSetTime, FileGetSize, FileGetVersion, File-loop

#### Examples

    FileSetAttrib, +RH, C:\MyFiles\*.*, 1  ; +RH is identical to +R+H
    FileSetAttrib, ^H, C:\MyFiles  ; Toggle the folder's "hidden" attribute.
    FileSetAttrib, -R+A, C:\New Text File.txt
    FileSetAttrib, +A, C:\*.ini, , 1  ; Recurse through all .ini files on the C drive.