Pasting one file to multiple folders using Python

Viewed 14

I have a file Test.py whose path is specified using src_path. I want to paste this file in multiple folders, named 1,2,3,4,5 and I specify the destination path using dst_path. It works when I manually enter i=1,2,3,4,5. However, the for-loop isn't working which will help me to paste into multiple folders in one go.

import shutil

src_path = r"C:\Users\USER\OneDrive - Technion\Research_Technion\Python_PNM\Sept15_2022\Test.py"
for i in range(1,6):
    dst_path = r"C:\Users\USER\OneDrive - Technion\Research_Technion\Python_PNM\Sept15_2022\{i}" 
    shutil.copy(src_path, dst_path)
    print('Copied')
0 Answers
Related