CLI commands that let you access meta data of all files in OSX

Posted on 14:29, July 31st, 2012 by
Many Ayromlou
Two small commands with huge possibilities:
- mdls
usage: mdls [-name attr] [-raw [-nullMarker markerString]] [-plist file] path
list the values of one or all the attributes of the specified file
-raw: don't print attribute names before values
-nullMarker: substitute this string for null attributes in raw mode
-plist: output attributes in XML format to file. Use - to write to stdout
option -plist is incompatible with options -raw, -nullMarker, and -name
example: mdls ~/Pictures/Birthday.jpg
example: mdls -name Keyword ~/Pictures/Birthday.jpg
- mdfind
Usage: mdfind [-live] [-count] [-onlyin directory] [-name fileName | -s smartFolderName | query]
list the files matching the query
query can be an expression or a sequence of words
-live Query should stay active
-count Query only reports matching items count
-onlyin <dir> Search only within given directory
-name <name> Search on file name only
-s <name> Show contents of smart folder <name>
-0 Use NUL (``\0'') as a path separator, for use with xargs -0.
example: mdfind image
example: mdfind -onlyin ~ image
example: mdfind -name stdlib.h
example: mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'"
example: mdfind -live MyFavoriteAuthor