Subarna Saha
Subarna Saha

Reputation: 115

Copy Specific folder from one location to another Python

I want to copy a specific folder from one location to another. I want the entire folder to be copied not just the contents of the folder.

I have tried as:

shutil.copytree(src, dst, symlinks=True)

But this copies the content of the folder, not the entire folder.

Upvotes: 1

Views: 72

Answers (1)

sjaymj62
sjaymj62

Reputation: 378

You can just do

shutil.copytree(src, os.path.join(dst, os.path.basename(src)), symlinks=True)

Some might disagree with this approach. but it does exactly what you need here.

Upvotes: 1

Related Questions