Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am in the middle of merging 2 directories into 1.

/competitions/1
/competitions/2
/competitions/3

/gallery/1
/gallery/2
/gallery/3

I want to copy all the files in /competitions to /gallery and put them in there respective folders. I can assume that all file names are unique and will not be copied over.

How can I do this with rsync?

share|improve this question

2 Answers

up vote 2 down vote accepted
rync -av /competitions/* /gallery 

should do the trick.

share|improve this answer

You really should check the manpages for rsync:

 This  would  recursively  transfer  all files from the directory src/bar on the machine foo into the /data/tmp/bar directory on the local machine. The files are transferred in "archive" mode,
       which ensures that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer.  Additionally, compression will be used to reduce the size  of  data  por-
       tions of the transfer.

  rsync -avz foo:src/bar/ /data/tmp

scp works just as well for this.

share|improve this answer
I'm not a huge techy and in most cases all the examples for rsync are over complicated and never cover the basics of a simple copy. So, would I be right in just rsync /competitions/ /gallery/ ? – David Dec 5 '11 at 15:35
If you're not copying these files across hosts, just use cp -R /competitions/* /gallery/ – thinice Dec 5 '11 at 15:39
A great way to use rsync quickly is to add aliases to your shell, try those two: rsynccopy="rsync --partial --progress --append -r -h" and rsyncmove="rsync --partial --progress --append -r -h --remove-source-files" – Shadok Dec 5 '11 at 16:10

Your Answer

 
discard

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.