Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy multiple directories with one command

Is there any way to copy multiple directories in one command, to reduce the number of layers? E.g., instead of:

COPY dirone ./dirone COPY dirtwo ./dirtwo COPY dirthree ./dirthree 

I want to do:

COPY dirone/ dirtwo/ dirthree/ ./ 

However, this copies the contents of the directories... but I want to copy the directories themselves.

like image 985
Claudiu Avatar asked Jun 09 '16 00:06

Claudiu


People also ask

How do you copy multiple folders?

To do this, click and hold your left mouse button on the top-left portion of where you want to start highlighting. Next, drag the box until the last file or folder is highlighted. Once the files are selected, they can be copied, cut, or dragged to another window to move them.

How do I copy multiple folders into multiple folders?

If you need to copy a file to multiple folders, you can hold down the Ctrl key, and drag the file or folder on to each folder you want to copy it to.

How do you copy a file to multiple folders at once in Linux?

The another way to copy files to multiple locations is by using echo , xargs and cp commands. As you already know, the cp command is used to copy the files and directories, and xargs command is used to build and execute command lines from standard input.

Can we copy multiple file by using single command?

Copy Multiple Files Using CP CommandYou must provide both the file name and the destination directory when using the cp command to copy multiple files. First, open the specific directory in the terminal and execute the tree command. If you don't know about the tree command, then please check out this blog.


1 Answers

That's the documented behavior of the copy command:

If <src> is a directory, the entire contents of the directory are copied, including filesystem metadata.

Note: The directory itself is not copied, just its contents.

Best workaround I can suggest is to change your directory layout in your build folder, move the three folders under one parent folder and add the parent.

like image 127
BMitch Avatar answered Sep 18 '22 19:09

BMitch