Find the answer to your Linux question:
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.
  1. #1
    Just 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.

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,318
    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:

    Code:
    dir1/
    dir1/file1.csv
    dir1/file2.csv
    dir1/dir2/new1.csv
    dir1/dir2/new2.csv
    dir1/dir2/text1.txt
    dir1/dir2/test2.txt
    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:
    find dir1/ -type f -name '*.csv' -exec install -Dv {} ./newdir/{} \;
    Again, this is probably not exactly what you are looking for, but share more details and we'll try to help you get there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •