ItSolutionStuff.com

Python Copy File From one Directory to Another Example

By Hardik Savani • October 30, 2023
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: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Python Get First Date of Last Month Example

Read Now →

Python Get First Date of Next Month Example

Read Now →

Python Create Zip Archive from Directory Example

Read Now →

How to Check if Today is Sunday or not in Python?

Read Now →

How to Check if Today is Wednesday or not in Python?

Read Now →

How to Check if Today is Tuesday or not in Python?

Read Now →

Python Check if Date is Weekend or Weekday Example

Read Now →

Python Subtract Seconds from DateTime Example

Read Now →

Python POST Request with Parameters Example

Read Now →

How to Get Current Minute in Python?

Read Now →

How to Get Current Hour in Python?

Read Now →

How to Get Current Month in Python?

Read Now →