21

I would like to ask if in OS X there is a similar functionality of "Get Info" (Cmd+I) but from the Mac OS X Terminal.app? I mean something like finderGetInfo /path/to/a/file.ext which will output the infos for the file but in the terminal console? Like this:

enter image description here

But from the command line:

Machine:~ antony$ finderGetInfo /Users/antony/file.ext
General:
   Kind: Document
   Size: 29 bytes (4 KB on disk)
   Where: /Users/antony
   Created: Today 08:58
   Modified: Today 08:58
   Stationery pad: NO
   Locked: NO
More Info:
   --
Name & Extension: file.ext
Comments: ...
etc...

It would be very useful when creating some automatic tools that need to extrapolate some useful information from a file of any type.

Is it possible in OS X?

32

mdls lists file metadata. A sample below for a folder

kMDItemContentCreationDate     = 2011-11-20 04:05:42 +0000
kMDItemContentModificationDate = 2014-10-22 01:52:53 +0000
kMDItemContentType             = "public.folder"
kMDItemContentTypeTree         = (
    "public.folder",
    "public.directory",
    "public.item"
)
kMDItemDateAdded               = 2014-10-17 09:19:38 +0000
kMDItemDisplayName             = "temp"
kMDItemFSContentChangeDate     = 2014-10-22 01:52:53 +0000
kMDItemFSCreationDate          = 2011-11-20 04:05:42 +0000
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = 0
kMDItemFSHasCustomIcon         = (null)
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSIsStationery          = (null)
kMDItemFSLabel                 = 0
kMDItemFSName                  = "temp"
kMDItemFSNodeCount             = 96
kMDItemFSOwnerGroupID          = 80
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = (null)
kMDItemFSTypeCode              = ""
kMDItemKind                    = "Folder"
kMDItemLastUsedDate            = 2014-12-03 03:57:48 +0000
kMDItemUseCount                = 2
kMDItemUsedDates               = (
    "2014-10-25 13:00:00 +0000",
    "2014-12-02 13:00:00 +0000"
)
  • This is really a good piece of news, thank you for answering so fast! – user3019105 Jan 6 '15 at 7:06
  • Would there be a way of just printing out a certain property? – Karoh Aug 16 '16 at 15:04
  • 1
    @Horak try reading man mdls – Milliways Aug 17 '16 at 0:07
  • 1
    mdls -name kMDItemContentCreationDate target_file_name_here is an example. – jasonleonhard Jan 9 '18 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .