python copy directory from one directory to another code example
Example 1: python copy file to another directory
import shutil
shutil.copy2('/src/dir/file.ext', '/dst/dir/newname.ext')
shutil.copy2('/src/file.ext', '/dst/dir')
Example 2: Copy any files from one folder to another folder in python
import shutil
import os
os.chdir('source_image_dir_path')
dst_dir = "your_destination_dir_path"
for f in os.listdir():
shutil.copy(f, dst_dir)
Example 3: copy directory from one location to another python
src = 'C:/Users / Rajnish / Desktop / GeeksforGeeks / source'
dest = 'C:/Users / Rajnish / Desktop / GeeksforGeeks / destination'
destination = shutil.copytree(src, dest)