user63598
0
Q:

python copy file

from shutil import copyfile
copyfile(src, dst)
5
import shutil

original = r'original path where the file is currently stored\file name.file extension'
target = r'target path where the file will be copied\file name.file extension'

shutil.copyfile(original, target)
3
from shutil import copyfile
copyfile(src, dst)
0
# 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