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). Note: If FilePattern is a single folder rather than a wildcard pattern, it will always be operated upon regardless of this setting. In v1.0.30.03+, this parameter can be an expression. |
Recurse? | 0 (default) Subfolders are not recursed into. In v1.0.30.03+, 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.
ErrorLevel
ErrorLevel is set to the number of files that failed to be changed (if any) or 0 otherwise.
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.