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. 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 sign (+), minus sign (-) or caret (^), respectively:

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

FilePattern
If blank or 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.
OperateOnFolders

If blank or omitted, it defaults to 0. Otherwise, specify one of the following digits:

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

If blank or omitted, it defaults to 0. Otherwise, specify one of the following digits:

This parameter can be an expression.

Error Handling

[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.

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

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.

FileGetAttrib, FileGetTime, FileSetTime, FileGetSize, FileGetVersion, file loop

Examples

Turns on the "read-only" and "hidden" attributes of all files and directories (subdirectories are not recursed into).

FileSetAttrib, +RH, C:\MyFiles\*.*, 1  ; +RH is identical to +R+H

Toggles the "hidden" attribute of a single directory.

FileSetAttrib, ^H, C:\MyFiles

Turns off the "read-only" attribute and turns on the "archive" attribute of a single file.

FileSetAttrib, -R+A, C:\New Text File.txt

Recurses through all .ini files on the C drive and turns on their "archive" attribute.

FileSetAttrib, +A, C:\*.ini, , 1