How to list all files with Finder Comment using unix? 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?
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 .