Results 1 to 2 of 2
I have a directory that contain some .csv files and also some sub directories those contained csv files. I need to copy only my folder structure with csv’s inside child ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-29-2011 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 26
Help for Copying directory structure recursively
I have a directory that contain some .csv files and also some sub directories those contained csv files. I need to copy only my folder structure with csv’s inside child directory without copying perant directory csv’s
(only need to exclude parent directory csv files)
I tried lot with rsync and cp but couldn’t make it please help.
---Sorry for bad explanation.
- 11-30-2011 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,657
Try giving us a listing of the directory and file structure and what you wish to copy and what you wish to exclude.
For example, I'll pretend you have this:
Let's say in the above example, you want to copy dir1/dir2/new*.csv, but not copy the files in dir1/file*.csv, nor the text files in dir1/dir2, and you wanted to retain the full directory structure (dir1/dir2) when copying to the new location (let's say /newdir). You could use a combination of find and install to do it, e.g.:Code:dir1/ dir1/file1.csv dir1/file2.csv dir1/dir2/new1.csv dir1/dir2/new2.csv dir1/dir2/text1.txt dir1/dir2/test2.txt
Again, this is probably not exactly what you are looking for, but share more details and we'll try to help you get there.Code:find dir1/ -type f -name '*.csv' -exec install -Dv {} ./newdir/{} \;


Reply With Quote
