Using shutil library to copy contents of a directory from src to dst, but not the directory itself

141 Views Asked by At

So I have a directory called /src, which has several contents:

a.png, file.text, /sub_dir1, /sub_dir2

I want to copy these contents into destination directory /dst such that the inside of /dst looks like this (assuming /dst is previously empty):

a.png, file.text, /sub_dir1, /sub_dir2

I have tried shutil.copytree(src, dst), but when I open up /dst I see:

/src

which, although contains everything I want, should not be there, as I do not want the /src directory itself copied over, only its inner contents. Does anyone know how to do this?

1

There are 1 best solutions below

0
On

I made a mistake with the file pathways I inputted into the copytree function. The function works as expected, in the way I mentioned I wanted it to in my question.