Python Copy File From one Directory to Another Example

By Hardik Savani October 30, 2023 Category : Python

Hi,

This tutorial will provide example of python copy file from one directory to another. We will use python copy file from one directory to another and rename. you can see python copy file from one location to another. We will use python copy file from a directory to another. So, let's follow few step to create example of python copy file example.

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.

You can use these examples with python3 (Python 3) version.

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.

I hope it can help you...

Tags :
Shares