How i can get path of all files, folders which has Finder comment and also the comment.

Like this: /path/here/file.txt TAB finder comment is here /path4/here2/folder TAB finder comment is here

I could first use this to find all items with comment:

mdfind kMDItemFinderComment == '*'

And then find the comments:

mdls -name kMDItemFinderComment pathhere

But is there a way to get all in single command?

  • Create a permanent alias for the combined commands, without including the path course.
    – pwn'cat
    Nov 20, 2015 at 16:03

2 Answers 2


This will do the trick:

 find . -xattrname com.apple.metadata:kMDItemFinderComment \
        -exec printf %s\\t {} \; \
        -exec mdls -name kMDItemFinderComment -raw {} \; \
        -exec echo \;

Breaking this down a little:

  • find looks through the current directory (.) (and everything "below") for files with an extended attribute (-xattrname) called com.apple.metadata:kMDItemFinderComment.
  • As it finds each file:
    • the first -exec argument uses printf to print out the file path and a tab (\t) character.
    • The second -exec runs mdls to read the actual comment.
    • The third -exec just prints out a newline (\n) character.

Note that the find command is recursive, so this solution will look through subdirectories as well.

If you require absolute paths then use find `pwd` instead of find .


No - you'll need to script the two commands together and loop over the list of files. It's a bit of a chore since you'll need to handle spaces in file names and unicode characters as well as potentially finding 100,000 files that match and avoid rolling your variable over the max length.

For small searches, you could probably stuff all the results in one variable and pipe things together, but that's liable to break under foreseeable real world uses.

You must log in to answer this question.

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