Answers for "copy file from one directory to another python"


python copy file to another directory

import shutil
shutil.copy2('/src/dir/file.ext', '/dst/dir/newname.ext') # complete target filename given
shutil.copy2('/src/file.ext', '/dst/dir') # target filename is /dst/dir/file.ext
Posted by: Guest on February-22-2021

copy image from one folder to another in python

import glob
import shutil
import os

src_dir = "your/source/dir"
dst_dir = "your/destination/dir"
for jpgfile in glob.iglob(os.path.join(src_dir, "*.jpg")):
    shutil.copy(jpgfile, dst_dir)
Posted by: Guest on November-27-2020

copy file in python3

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)
Posted by: Guest on May-21-2020

copy directory from one location to another python

# 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)
Posted by: Guest on April-14-2021

copyfile pyhon

from shutil import copyfile
copyfile(src, dst)
Posted by: Guest on October-03-2020

Code answers related to "copy file from one directory to another python"

Python Answers by Framework

Browse Popular Code Answers by Language