Move & Rename Files Using Python
Python - General Python
An example of using the os rename function to copy a file to a different location and change the name, in other words to change the file path using Python. In this instance the sales.csv file is renamed to BookSales.csv and is copied from the data folder to the archive folder.
import os original_file_path = 'D:\data\sales.csv' new_file_path = 'D:\archive\BookSales.csv' os.rename(original_file_path,new_file_path)
By GregHe1979 - Last Updated Sept. 8, 2021, 10:12 p.m.