GetFileInfo - macOS


GetFileInfo is a command-line utility in macOS used to display the metadata attributes of files and directories within the file system. It is commonly utilized by developers and system administrators to retrieve specific file information, such as type, creator code, attributes, and timestamps, which can assist in scripting, debugging, and system maintenance.


The general syntax for using GetFileInfo is as follows:

GetFileInfo [options] file_path
  • file_path is the path to the file or directory for which you want to retrieve information.

Multiple files can be queried by appending more file paths at the end of the command.


GetFileInfo includes several options that allow users to specify the type of information they wish to retrieve:

  • -a: Displays the Finder attributes.
  • -b: Displays the file’s creation date in mm/dd/yyyy hh:mm:ss format.
  • -c: Displays the file’s creator code.
  • -d: Displays the file’s modification date in mm/dd/yyyy hh:mm:ss format.
  • -m: Displays file’s last modification time.
  • -P: Treats the next argument as a literal path of the file.
  • -t: Displays the type code of the file.
  • -T: Uses Unix time for displaying creation and modification dates.

Use combinations of these flags to retrieve multiple pieces of information simultaneously.


  1. View the type code and creator code of a file:
    GetFileInfo -t -c path/to/file.txt
  2. Get the modification date of multiple files:
    GetFileInfo -d file1.png file2.jpg
  3. Display all metadata available for a specific file:
    GetFileInfo -a -b -c -d -m -t /path/to/document.pdf

Common Issues

  • Permission Denied: Users might encounter access issues if they do not have the necessary permissions to access certain files or directories. Using sudo can overcome these permissions issues:
    sudo GetFileInfo path/to/protected_file
  • Invalid Flags Combination: Some combinations of flags might not work together or return conflicting information. Always refer to the manual to ensure compatibility between options.


Combine GetFileInfo with other commands to perform automated tasks or complex queries. For example, to archive files that were modified before a specific date:

find . -type f -exec bash -c '[[ $(GetFileInfo -d "$1") < "01/01/2020" ]] && tar -rvf archive.tar "$1"' _ {} \;
  • ls: Lists directory contents and can show limited file information.
  • mdls: Lists the metadata attributes for files on macOS.
  • stat: Display file or file system status.

Further details and official documentation can be explored through the macOS developer resources or manual pages for each respective command.