Hello All…good day…I am creating a python script to copy files from folder/subfolders into another folder. I did with all success. But I want to rename the copied files into different file name as code. Example, let say i got 3 files copied (file name aa.doc, bb.doc, & cc.doc). After copied I want to save those files into another folder with filenames P001.doc, P002, and P003 respectively. Really need your help. Below is my code.
import os
import shutil
source_folder = r"E:\files\reports\\"
destination_folder = r"E:\files\finalreport\\"
for root, dirs, files in os.walk(source_folder):
for file in files:
src_file_path = os.path.join(root, file)
dst_file_path = os.path.join(destination_folder, file)
shutil.copy(src_file_path, dst_file_path)