nandy
0
Q:

shutil.copytree

# Python program to explain shutil.copytree() method  
       
# importing os module  
import os  
   
# importing shutil module  
import shutil  
   
# path  
path = 'C:/Users / Rajnish / Desktop / GeeksforGeeks'
   
# List files and directories  
# in 'C:/Users / Rajnish / Desktop / GeeksforGeeks'  
print("Before copying file:")  
print(os.listdir(path))  
   
   
# Source path  
src = 'C:/Users / Rajnish / Desktop / GeeksforGeeks / source'
   
# Destination path  
dest = 'C:/Users / Rajnish / Desktop / GeeksforGeeks / destination'
   
# Copy the content of  
# source to destination  
destination = shutil.copytree(src, dest)  
   
# List files and directories  
# in "C:/Users / Rajnish / Desktop / GeeksforGeeks"  
print("After copying file:")  
print(os.listdir(path))  
   
# Print path of newly  
# created file  
print("Destination path:", destination) 
1

New to Communities?

Join the community