Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

Possible Duplicate:
How can I copy a subset of files from a directory while preserving the folder structure?

I have a bunch of directories like this:

/Artists/Example Name 1/Images/Lo-res/
/Artists/Example Name 2/Images/Lo-res/
/Artists/Example Name 3/Images/Lo-res/

I want to use the cp command to copy all the contents of all of the "Lo-res" directories to another location while keeping their preceding directory structure (the name and images directories) intact.

I've been trying this

cp -R /Artists/*/Images/Lo-res /New_Location/

But that just copies all the files into one new Lo-res folder.

Can anyone help?

share|improve this question

migrated from stackoverflow.com Nov 30 '12 at 13:39

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Mikel, Renan, jw013, jasonwryan, Gilles Nov 30 '12 at 20:59

This question was marked as an exact duplicate of an existing question.

That's what cp does. I think you need to use something else to get the effect you want, such as tar. – Celada Nov 29 '12 at 23:08
Check out rsync and its filter rules – Abe Voelker Nov 29 '12 at 23:10

rsync -av /Artists/*/Images/Lo-res/ /New_location/

the trailing / characters on the source and destination directories are very important to rsync to attain the effect you want.

share|improve this answer