1

I want to copy all the images from one folder to another. I have tried this !cp -r /content/COVID-19\ Radiography\ Database/COVID-19 /data

but this creates a folder COVID-19 in the data folder, and I don't want to create COVID-19 folder in data, instead, I want to copy images directly.

EDIT This command copying all files but in COVID-19 folder which is in data folder. i want them directly in data folder

Talha Anwar
  • 139
  • 1
  • 5
  • Try with this (check the first answer, that oen that says about folder 1 and folder 2) [https://askubuntu.com/questions/86822/how-can-i-copy-the-contents-of-a-folder-to-another-folder-in-a-different-directo](https://askubuntu.com/questions/86822/how-can-i-copy-the-contents-of-a-folder-to-another-folder-in-a-different-directo) PD: try to copy the final path(where would be the new folder) and past it in the console from the file explorer, maybe the problem is there. – Munsko Apr 01 '20 at 17:29

3 Answers3

3

Try using a wildcard to grab everything in the folder.

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

The original command is interpreted as copy this folder (COVID-19) to folder /data. The wildcard will say to take all of the files in that folder and copy them to /data.

Robby1212
  • 870
  • 1
  • 10
  • 26
3
cp -a /source/. /dest/

-a is for recursive copy and . at the end is for copying the hidden files too.

PHP Worm...
  • 181
  • 1
  • 2
0

This code with Flag "-R" copies perfectly all the contents of "folder1" to existing "folder2":

cp -R folder1/. folder2

Flag "-R" copies symbolic links as well but Flag "-r" skips symbolic links so Flag "-R" is better than Flag "-r".

  • The latest GNU Grep 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.