I have a directory-tree with a lot of files in it. I'd like to copy all of those files into one new directory, but with all files located in the base of the 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'd 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'm pretty sure there is a bashcommand for that, but I haven't found it yet. Do you have any ideas?
CS
To copy multiple files with the “cp” command, navigate the terminal to the directory where files are saved and then run the “cp” command with the file names you want to copy and the destination path.
Type "xcopy", "source", "destination" /t /e in the Command Prompt window. Instead of “ source ,” type the path of the folder hierarchy you want to copy. Instead of “ destination ,” enter the path where you want to store the copied folder structure. Press “Enter” on your keyboard.
To copy a directory with all subdirectories and files, use the cp command.
In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied.
find /source-tree -type f -exec cp {} /target-dir \;
you are looking for ways to flatten the directory
find /images -iname '*.jpg' -exec cp --target-directory /newfolder/ {} \;
find
all files iname
in case insensitive name mode.cp
copy once to --target-directory
named /newfolder/
.{}
expand the list from find
into the form of /dir/file.jpg /dir/dir2/bla.jpg
.
On zsh:
cp /source/**/* /destination
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With