mdls

From Mac Guides

Jump to: navigation, search

Image:Tiger_small.jpg

This tip requires
Mac OS X Tiger

mdls is a Terminal command for listing metadata contents of any file, as seen by Spotlight. It accepts a filename as an argument and returns a list of metadata, in a key=value pair. The results may easily be filtered with grep, or initially constrained to provide the appropriate data.

Examples

To list all the metadata of a file called "Picture.jpg" in your Documents folder:

 mdls ~/Documents/Picture.jpg

To return just the width of an image:

 mdls -name kMDItemPixelWidth Picture.jpg

Man Page Excerpt

The mdls command prints the values of all the metadata attributes associated with the files provided as an argument.

See Also