James
James

Reputation: 2406

How do I sync two local file structures

I have two large source trees. One of them has some out of date image files. I would like to automatically update all the old image files (png, jpg, gif) in one source tree with the up to date image files in the other source tree.

I am using Windows 7 but I have Cygwin installed. I have tried using rsync so far but with no success.

I was hoping I could do something like:

rsync -r *.png newSourceTree oldSourceTree

If there is some other way of achieving the same thing e.g. a Perl or Bash script, I'd be open to using that too.

Any help would be much appreciated.

Thanks, James.

Upvotes: 4

Views: 511

Answers (3)

Norman Ramsey
Norman Ramsey

Reputation: 202505

Unison is designed for exactly this sort of problem. You can synchronize all the files using

unison oldTree newTree -force newer

If you want it to touch only image files, read the documentation.

Upvotes: 1

jmanning2k
jmanning2k

Reputation: 9478

You want:

rsync -av --include '*.png' --include '*/' --exclude '*' newSourceTree/ oldSourceTree/

A quick explanation: You want to include png files, include all directories (so that it can recurse), then exclude everything else. Include/Exclude are processed left to right, and default to including everything.

Upvotes: 2

Alex K.
Alex K.

Reputation: 175786

What about:

robocopy c:\source\ c:\destination\ *.png *.gif /s

Upvotes: 1

Related Questions