Skip to content

All topics  /  Python

Copy File From one Directory to Another in Python

Python

Sep 21, 2022

Hi Dev,

Are you looking for example of Copy File From one Directory to Another in Python. step by step explain Python Copy File Example. I would like to share with you Python Copy File Shutil Example. We will use Python Copy File from a Directory to Another. follow bellow step for Python Copy File from One Location to Another.

In this example, I will give you a simple example of a copy a file from one directory to another. so let's see a simple example with output.

so let's see following examples with output:

Example


main.py

import shutil
srcFilePath = "files/image1.png"
destinationFilePath = "copyFiles/image1.png"
shutil.copyfile(srcFilePath, destinationFilePath)
print("File Copy Successfully.")

Output:

File Copy Successfully.