setfile - macOS


setfile is a versatile macOS command-line tool that allows users to modify file attributes and metadata. It provides precise control over file and directory properties, making it invaluable for system administrators, developers, and advanced users.


setfile [-abcefinrsv] [-d mask] [-e value] [-g value] [-o value] [-p value] [-t value] file...


  • -a: Adds the specified attributes to the file.
  • -b: Backs up the original file before making changes.
  • -c: Continues processing even if errors occur.
  • -d: Modifies the file’s data fork protection mask.
  • -e: Sets the effective user ID for the file.
  • -f: Changes the file type and creator code.
  • -g: Sets the group ID for the file.
  • -i: Ignores files that cannot be modified.
  • -n: Prints the attributes without changing them.
  • -o: Sets the file owner.
  • -p: Patches a property list in a file.
  • -r: Processes files recursively within directories.
  • -s: Sets the file size.
  • -t: Sets the modification time.
  • -v: Verbose output mode.


  • Set file ownership: setfile -o myuser myfile
  • Change file permissions: setfile -m 755 myfile
  • Modify file type and creator: setfile -f TEXT myfile
  • Set file modification time: setfile -t "2023-03-08 10:30:00" myfile
  • Patch a property list in a file: setfile -p key=value myfile.plist

Common Issues

  • Permission denied: Ensure that you have sufficient permissions to modify the file or folder.
  • File not found: Check if the specified file path is correct.
  • Invalid attribute: Verify that the specified attribute is supported by the file system.


  • Use with other commands: Combine setfile with commands like ls and find to filter and modify files based on specific criteria.
  • Automate tasks: Create scripts that utilize setfile to automate repetitive file attribute management tasks.
  • xattr
  • chflags
  • chmod
  • chown