Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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".

share|improve this question
up vote 2 down vote accepted

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
share|improve this answer
I was hoping rsync would take a "predicate function" for its filtering so that it would run it against all candidate files.. – Robottinosino Jun 8 '12 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:, section FILTER RULES. – Ian C. Jun 8 '12 at 14:43
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 :) – Robottinosino Jun 8 '12 at 14:54
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. Jun 8 '12 at 15:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.