Copy each file of the entire directory structure to the base path of another

I have a directory tree with a lot of files. I would like to copy all these files to one new directory, but with all the files located in the database folder.

So, I have something like this:

images β”œβ”€β”€ avatar.png β”œβ”€β”€ bg.jpg β”œβ”€β”€ checkbox.png β”œβ”€β”€ cross.png β”œβ”€β”€ datatables β”‚  β”œβ”€β”€ back_disabled.png β”‚  β”œβ”€β”€ back_enabled.png β”‚  β”œβ”€β”€ forward_disabled.png β”‚  β”œβ”€β”€ forward_enabled.png β”‚  β”œβ”€β”€ sort_asc.png β”‚  β”œβ”€β”€ sort_asc_disabled.png β”‚  β”œβ”€β”€ sort_both.png β”‚  β”œβ”€β”€ sort_desc.png β”‚  └── sort_desc_disabled.png β”œβ”€β”€ exclamation.png β”œβ”€β”€ forms β”‚  β”œβ”€β”€ btn_left.gif β”‚  β”œβ”€β”€ btn_right.gif β”‚  β”œβ”€β”€ checkbox.gif β”‚  β”œβ”€β”€ input β”‚  β”‚  β”œβ”€β”€ input_left-focus.gif β”‚  β”‚  β”œβ”€β”€ input_left-hover.gif β”‚  β”‚  β”œβ”€β”€ input_left.gif β”‚  β”‚  β”œβ”€β”€ input_right-focus.gif β”‚  β”‚  β”œβ”€β”€ input_right-hover.gif β”‚  β”‚  β”œβ”€β”€ input_right.gif β”‚  β”‚  β”œβ”€β”€ input_text_left.gif β”‚  β”‚  └── input_text_right.gif β”‚  β”œβ”€β”€ radio.gif β”‚  β”œβ”€β”€ select_left.gif β”‚  β”œβ”€β”€ select_right.gif 

And I would like something like this:

  new_folder β”œβ”€β”€ avatar.png β”œβ”€β”€ bg.jpg β”œβ”€β”€ checkbox.png β”œβ”€β”€ cross.png β”œβ”€β”€ back_disabled.png β”œβ”€β”€ back_enabled.png β”œβ”€β”€ forward_disabled.png β”œβ”€β”€ forward_enabled.png β”œβ”€β”€ sort_asc.png β”œβ”€β”€ sort_asc_disabled.png β”œβ”€β”€ sort_both.png β”œβ”€β”€ sort_desc.png β”œβ”€β”€ sort_desc_disabled.png β”œβ”€β”€ exclamation.png β”œβ”€β”€ btn_left.gif β”œβ”€β”€ btn_right.gif β”œβ”€β”€ checkbox.gif β”œβ”€β”€ input_left-focus.gif β”œβ”€β”€ input_left-hover.gif β”œβ”€β”€ input_left.gif β”œβ”€β”€ input_right-focus.gif β”œβ”€β”€ input_right-hover.gif β”œβ”€β”€ input_right.gif β”œβ”€β”€ input_text_left.gif β”œβ”€β”€ input_text_right.gif β”œβ”€β”€ radio.gif β”œβ”€β”€ select_left.gif β”œβ”€β”€ select_right.gif 

I am sure there is bashcommand for this, but I have not found it yet. Do you have any ideas?

CS

+16
linux bash find folder cp
Mar 21 '12 at 8:29
source share
4 answers

you are looking for ways to smooth the directory

 find /images -iname '*.jpg' -exec cp --target-directory /newfolder/ {} \; 

find all iname files in case of case insensitive name mode.
copy cp once to --target-directory with the name /newfolder/ .
{} expand the list from find into the form /dir/file.jpg /dir/dir2/bla.jpg .

+12
Mar 21 2018-12-12T00:
source share
 find /source-tree -type f -exec cp {} /target-dir \; 
+26
Mar 21 2018-12-12T00:
source share

In zsh :

cp /source/**/* /destination

+2
Feb 14 '16 at 15:59
source share
 $ cd images && cp ** new_folder/ 
-2
May 02 '15 at 19:32
source share



All Articles