WeirdGeek

Data Science | Machine Learning | Automation

  • Data Analytics
  • Python
  • Data Science
  • Google Apps Script
  • Machine Learning
  • Artificial Intelligence
  • SQL Server

12/04/2019 By WeirdGeek Leave a Comment

Python Script to transfer file from one location to another

Python Script to transfer file from one location to another

Python is very useful for performing basic tasks like transferring the file from one location to another with few lines of code. The best of using python is that there are already loads of packages that contains already written functions and codes which you can reuse while working on your project.

Also, Python scripts are preferred when it comes to automating boring tasks. Check out this post which helps you in automating the python script to run daily using Windows task scheduler.

Let’s see the code which you can use to transfer the file from one location to another. Here we have used two packages, one is shutil and another is time.

Python Script to transfer the file from one location to another:

#Importing shutil and time package
import shutil
import time
try:
    print("Copying File")
    #Provide the path to the file which you want to copy
    src = "Path-to-file"
    #Provide path to the destination folder
    dst = "destination-path-where-we-want-to-save-the-file"
    #Using shutil's .copy() function which 
    #include source and destination path
    shutil.copy(src,dst)
    time.sleep(1)
    print("Successfully Completed")
    time.sleep(0.5)
except:
    print("Unsuccessful!! Error Generated")
    time.sleep(2)

‘
Hope this helps and you can use this Python Script to transfer the file from one location to another. If you need any help, please feel free to reach out via comments below.

Related posts:

  1. Setting up Python Development Environment for Data Analysis
  2. Creating and Computing over Dictionaries in Python
  3. Find and Copy files of specific types using Google Apps Script
  4. Reading 15 most common file formats used in Data Science (using Python)

Filed Under: Python Tagged With: Python, Python Script

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe to my Blog !!

Enter your email below to subscribe my blog and get the latest post right in your inbox.

  • Home
  • Terms
  • Privacy
  • Contact Us

Copyright © 2025 · WeirdGeek · All trademarks mentioned are the property of their respective owners.