Changes the attributes of one or more files or folders. Wildcards are supported.
FileSetAttrib Attributes , FilePattern, Mode
Type: String
The attributes to change. For example, "+HA-R"
.
To easily turn on, turn off or toggle attributes, prefix one or more of the following attribute letters with a plus (+), minus (-) or caret (^) symbol, respectively:
If no symbol precedes the attribute letters, the file's attributes are replaced with the given attributes. See example #5. To remove all attributes, use "N"
on its own.
Type: String
If omitted, the current file of the innermost enclosing file loop will be used. Otherwise, specify 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.
Both asterisks (*
) and question marks (?
) are supported as wildcards. *
matches zero or more characters and ?
matches any single character. Usage examples:
*.*
or *
matches all files.*.htm
matches files with the extension .htm, .html, etc.*.
matches files without an extension.log?.txt
matches e.g. log1.txt but not log10.txt.*report*
matches any filename containing the word "report".Type: String
If blank or omitted, only files are operated upon and subdirectories are not recursed into. Otherwise, specify one or more of the following letters:
An Error is thrown if any files failed to be changed, with its Extra property 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 compression state of files cannot be changed with this function.
FileGetAttrib, FileGetTime, FileSetTime, FileGetSize, FileGetVersion, file loop
Turns on the "read-only" and "hidden" attributes of all files and directories (subdirectories are not recursed into).
FileSetAttrib "+RH", "C:\MyFiles\*.*", "DF" ; +RH is identical to +R+H
Turns off the "read-only" attribute and turns on the "archive" attribute of a single file.
FileSetAttrib "-R+A", "C:\New Text File.txt"