0

I wanted to copy, entire folder structure, with files(may be using xcopy). The criteria is that the folder structure should have a particular folder name. For example , I want to copy the entire folder structure, where folder name has "ABC"(all the folder structure should be copied, whereever "ABC" folder name is present - rest should not be). If it is not possible in xcopy, is there anything in UNix?

2
  • Just a note: in Unix you have "directories", not "folders".
    – user235731
    Commented Jul 22, 2013 at 14:42
  • I am not quite sure what you are asking. Could you give an example folder name of what you want to copy and what you don't?
    – terdon
    Commented Jul 22, 2013 at 15:27

1 Answer 1

1

Assuming I understood you correctly:

find directory/ -type d -name "ABC" && cp -r directory/ destination/

This will recursively copy directory to destination as long as directory contains a sub-directory called ABC.

3
  • Not sure, why. I get a "bash: [: too many arguments" error. Could it be because of the version?
    – Suresh
    Commented Jul 22, 2013 at 16:51
  • There shouldn't have been any brackets. I'm not sure why I added those. I edited my answer.
    – user235731
    Commented Jul 22, 2013 at 17:24
  • This will actually copy everything recursively from directory to destination, whenever "ABC" is present. The source contains a lot of unwanted directories, I dont want to copy all the branches. I want to copy the braches, wherever "ABC" folder is present from source to destination. Sorry if my question was not clear.
    – Suresh
    Commented Jul 23, 2013 at 10:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .