[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Could rsync do something like robocopy does?



On Mon, Jan 16, 2012 at 12:19:27PM +0000, TCP wrote:
> Thanks, this works perfectly what I want.
> btw, what does the --include '*/' does?

According to the man page the --include '*/' includes all the directories, without which it won't actually look in any directories (even though it's recursive) because they'll be blocked by the --exclude '*'.

> Wouldn't --exclude '*' exclude all files even the cover.jpg?
> 

I think it processes the options in order, left to right, and stops at the first match (like I said, it is untested so I stand to be corrected). So, with the options I suggested rsync should, I think, use the following logic: Is it a file matching the pattern '*/'? (i.e. a directory. If yes -> include) If not, is it a file matching the pattern 'cover.jpg'? (If yes -> include) If not, is it a file matching the pattern '*'? (i.e. anything at all! If yes -> exclude).

This is why I needed to add the --prune-empty-dirs option, as the --include '*/' will make it copy all the directories, even if there are not files called 'cover.jpg' in them, and --prune-empty-dirs tells it not to bother copying directories which would be empty.

Hope this helps,
Laurence


Reply to: