On OS X, can I rsync selectively based on the file label as set in the Finder?

e.g. rsync all files and directories labelled "green".

1 Answer 1


Not with rsync alone. rsync doesn't know how to read or act on OS X file meta data, which labels happen to be. But, you can pass rsync an explicit list of files to sync. Combine this with the fact that you can use mdls to read label information on files from the command line and you could build a list of files and send that list to rsync.

> mdls -name kMDItemFSLabel Amanda\ Palmer\ \&\ The\ Grand\ Theft\ Orchestra\ --\ Do\ It\ With\ a\ Rockstar.mp3 
kMDItemFSLabel = 4
  • I was hoping rsync would take a "predicate function" for its filtering so that it would run it against all candidate files.. Commented Jun 8, 2012 at 14:36
  • Filters are as good as it gets in rsync and they can't run commands or scripts for you to determine filter applicability. It's pattern based filtering only. See: samba.org/ftp/rsync/rsync.html, section FILTER RULES.
    – Ian C.
    Commented Jun 8, 2012 at 14:43
  • 4
    I found my solution: build a file list using mdfind (e.g. mdfind -onlyin Media/E-Books "kMDItemFSLabel == 2") and feed it into rsync. You did not recommend mdfind but I am going to accept your answer anyway :) Commented Jun 8, 2012 at 14:54
  • 1
    That's kind. Glad I could steer you in the right direction. You can answer your own question though. I'd upvote that.
    – Ian C.
    Commented Jun 8, 2012 at 15:06

You must log in to answer this question.

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