How To Copy Specific File Types While Keeping Directory Structure In Linux
This brief tutorial explains how to copy specific file types while keeping the directory structure in Linux. Here I have given two different ways to do this. Just pick any one that works for you.
Copy Specific File Types While Keeping Directory Structure In Linux. I have a directory named “Linux” with different type of files saved in different sub-directories. Have a look at the following directory structure:
$ tree Linux/ Linux/ ├── dir1 │ ├── English │ │ └── Kina – Can We Kiss Forever.mp3 │ ├── Instrumental │ │ └── Chill Study Beats.mp3 │ └── Tamil │ ├── Kannan Vanthu.mp3 │ └── yarenna.mp3 ├── dir2 │ ├── file.docx │ └── Raja Raja Chozan Naan.mp3 ├── dir3 │ ├── Bamboo Flute – Meditation – Healing – Sleep – Zen.mp3 │ └── pic.jpg └── dir4 ├── Aaruyirae.mp3 └── video.mp4 7 directories, 10 files 
As you see in the above directory structure, the Linux directory has four sub-directories namely dir1, dir2, dir3 and dir4. The mp3 files are scattered across all four sub-directories. Now, I want to copy all mp3 files to another directory named “ostechnix” and also I want to keep the same directory structure in the target directory.
First we will see how to do this using “find” command.
[mai mult...]




