Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Copy specific file type keeping the folder structure

I have a folder structure with a bunch of .csv files scattered across the folders. Now I want to copy all *.csv files to another destination keeping the folder structure.

It works by doing:
cp --parents *.csv /target
cp --parents */*.csv" /target
cp --parents */*/*.csv /target
cp --parents */*/*/
.csv /target
...


and so on, but I would like to do it using one command.
by

1 Answer

Bharatgxwzm
find has a very handy -exec option:
find . -name '*.csv' -exec cp --parents \{\} /target \;

Login / Signup to Answer the Question.