Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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
2  
Check out rsync and its filter rules –  Abe Voelker Nov 29 '12 at 23:10

1 Answer 1

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