Transferring all files from one directory to another [duplicate]

The system displayed an error message upon execution of the following commands: “To copy all files from the ‘new’ folder created from July 20th until today’s date,” and “this command copied all files into a subfolder located within the ‘new’ folder.


I attempted to duplicate a folder’s images into another folder, and utilized the following code:

!cp -r /content/COVID-19 Radiography Database/COVID-19 /data


The current action results in the creation of a folder named


within the


folder. However, I do not wish to create a


folder within


. Instead, I would like to directly copy the images without creating any additional folders.

The command is designed to copy all files from


folder, except those in the


folder, and move them directly to the



Solution 1:

Consider employing a wildcard to capture all the contents within the folder.

!cp -r /content/COVID-19 Radiography Database/COVID-19/* /data

The initial instruction is to duplicate


directory into


directory. The asterisk symbol implies that all files in the former directory should also be copied to



Solution 2:

cp -a /source/. /dest/



function facilitates recursive copying, while the


command at the end ensures the copying of
hidden files
as well.

Solution 3:

By using the flag “-R”, all the contents of “folder1” can be copied perfectly to the already existing “folder2”.

cp -R folder1/. folder2

When using the “-R” flag, symbolic links are also copied, whereas the “-r” flag skips them. Therefore, the “-R” flag is superior to the “-r” flag.

  • The most recent version of GNU Grep is 3.7.
-R, --dereference-recursive
For each directory operand, read and process all files in that directory, 
recursively, following all symbolic links.
-r, --recursive
For each directory operand, read and process all files in that directory, 
recursively. Follow symbolic links on the command line, but skip symlinks 
that are encountered recursively. Note that if no file operand is given, 
grep searches the working directory. This is the same as the 
‘--directories=recurse’ option.

Frequently Asked Questions