Skip to content

setfile MacOS command

The MacOS setfile command allows users to set or get various attributes of a file or directory, such as flags, type, creator, and more. This command can be useful for managing file permissions, metadata, and other properties on macOS systems. By using the setfile command, users can easily modify and view file attributes directly from the terminal, providing a convenient way to customize file settings without the need for a graphical user interface.

Terminal window
setfile [-a options] file ...
OptionDescription
-aSet the file attributes specified by options.
ParameterDescription
optionsThe attributes to be set on the specified file(s).
fileThe file(s) for which the attributes are to be modified.
Terminal window
setfile -a C ~/Documents/example.txt

Add a custom label (color) to the file “example.txt” in the “Documents” folder.

Terminal window
setfile -d ~/Downloads/picture.jpg

Remove any custom label from the file “picture.jpg” in the “Downloads” folder.

Terminal window
setfile -I ~/Desktop/secret.docx

Make the file “secret.docx” on the Desktop invisible in the Finder.

Terminal window
setfile -a ~/Music/song.mp3

Show the extended attributes, including labels, of the file “song.mp3” in the “Music” folder.

Terminal window
setfile -a L ~/Desktop/important.pdf

Prevent the file “important.pdf” on the Desktop from being moved to the trash by locking it.

Set a file to be visible after being hidden

Section titled “Set a file to be visible after being hidden”
Terminal window
setfile -a V ~/Documents/hidden.txt

Make the hidden file “hidden.txt” in the “Documents” folder visible again in the Finder.

To use the setfile command in MacOS, execute the following command:

Terminal window
setfile --name example.txt

The setfile command in MacOS is used to set or get attributes of HFS+ file system.

Terminal window
setfile -a D example.txt

How can I view the attributes of a file using setfile in MacOS?

Section titled “How can I view the attributes of a file using setfile in MacOS?”

You can view the attributes of a file using setfile in MacOS by running the following command:

Terminal window
setfile -a example.txt

Can setfile be used to set the type of a file in MacOS?

Section titled “Can setfile be used to set the type of a file in MacOS?”

Yes, you can set the type of a file using setfile in MacOS. Here is an example command:

Terminal window
setfile -t TYPE example.txt

How do I remove all attributes from a file using setfile in MacOS?

Section titled “How do I remove all attributes from a file using setfile in MacOS?”

To remove all attributes from a file using setfile in MacOS, you can run the following command:

Terminal window
setfile -d example.txt

Is there a way to recursively set attributes for files in a directory using setfile in MacOS?

Section titled “Is there a way to recursively set attributes for files in a directory using setfile in MacOS?”

Yes, you can recursively set attributes for files in a directory using setfile in MacOS by using the -R option. Here’s an example:

Terminal window
setfile -R -t TYPE directory

How can I set the creator code of a file with setfile in MacOS?

Section titled “How can I set the creator code of a file with setfile in MacOS?”

To set the creator code of a file using setfile in MacOS, you can use a command like this:

Terminal window
setfile -c CREATOR example.txt

Can setfile be used to hide a file in MacOS?

Section titled “Can setfile be used to hide a file in MacOS?”

Yes, you can hide a file in MacOS using setfile. Here is a sample command:

Terminal window
setfile -a V example.txt
  • Setting file type and creator codes
  • Modifying file attributes
  • Controlling Finder attributes
  • Manipulating file metadata