<!--
{
  "availability" : [
    "iOS: 2.0.0 - 2.0.0",
    "iPadOS: 2.0.0 - 2.0.0",
    "tvOS: 9.0.0 - 9.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManager/changeFileAttributes(_:atPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)changeFileAttributes:atPath:"
  },
  "title" : "changeFileAttributes(_:atPath:)"
}
-->

# changeFileAttributes(_:atPath:)

Changes the attributes of a given file or directory.

```
func changeFileAttributes(_ attributes: [AnyHashable : Any] = [:], atPath path: String) -> Bool
```

## Parameters

`attributes`

A dictionary containing as keys the attributes to set for `path` and as values the corresponding value for the attribute. You can set following: `NSFileBusy`, `NSFileCreationDate`, `NSFileExtensionHidden`, `NSFileGroupOwnerAccountID`, `NSFileGroupOwnerAccountName`, `NSFileHFSCreatorCode`, `NSFileHFSTypeCode`, `NSFileImmutable`, `NSFileModificationDate`, `NSFileOwnerAccountID`, `NSFileOwnerAccountName`, `NSFilePosixPermissions`. You can change single attributes or any combination of attributes; you need not specify keys for all attributes.

    For the     `NSFilePosixPermissions`     value, specify a file mode from the OR’d permission bit masks defined in     `sys/stat.h`    . See the man page for the     `chmod`     function (    `man 2 chmod`    ) for an explanation.

`path`

A path to a file or directory.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if *all* changes succeed. If any change fails, returns <doc://com.apple.documentation/documentation/Swift/false>, but it is undefined whether any changes actually occurred.

## Discussion

As in the POSIX standard, the app either must own the file or directory or must be running as superuser for attribute changes to take effect. The method attempts to make all changes specified in attributes and ignores any rejection of an attempted modification.

The `NSFilePosixPermissions` value must be initialized with the code representing the POSIX file-permissions bit pattern. `NSFileHFSCreatorCode` and `NSFileHFSTypeCode` will only be heeded when `path` specifies a file.

### Special Considerations

Because this method does not return error information, it has been deprecated as of OS X v10.5. Use [`setAttributes(_:ofItemAtPath:)`](/documentation/Foundation/FileManager/setAttributes(_:ofItemAtPath:)) instead.

## See Also

[`attributesOfItem(atPath:)`](/documentation/Foundation/FileManager/attributesOfItem(atPath:))

Returns the attributes of the item at a given path.

[`setAttributes(_:ofItemAtPath:)`](/documentation/Foundation/FileManager/setAttributes(_:ofItemAtPath:))

Sets the attributes of the specified file or directory.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)