Changes the attributes of one or more files or folders. Wildcards are supported.
FileSetAttrib Attributes , FilePattern, Mode
The attributes to change (see Remarks).
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.
Zero or more of the following letters:
D: Include directories (folders).
F: Include files. If both F and D are omitted, files are included but not folders.
R: 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. If R is omitted, files and folders in subfolders are not included.
Note: If FilePattern is a single folder rather than a wildcard pattern, it will always be operated upon regardless of this setting.
An exception is thrown if any files failed to be changed, and Exception.Extra is set to the number of failures.
If files were found, A_LastError is set to 0 (zero) or the result of the operating system's GetLastError() function immediately after the last failure. Otherwise A_LastError contains an error code that might indicate why no files were found.
The Attributes parameter consists of a collection of operators and attribute letters.
|+||Turn on the attribute|
|-||Turn off the attribute|
|^||Toggle the attribute (set it to the opposite value of what it is now)|
|If no operator precedes the attribute letters, the file's attributes are replaced with the given attributes. To remove all attributes, use "N" on its own.|
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 function.
FileGetAttrib, FileGetTime, FileSetTime, FileGetSize, FileGetVersion, File-loop
FileSetAttrib "+RH", "C:\MyFiles\*.*", "DF" ; +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", "R" ; Recurse through all .ini files on the C drive.