how to copy files from different sources to different destinations using phyton?

Hi

I need to copy a file from a source folder to two different destination folders.

I tried this but not working

import os
import shutil


src = 'E:/source/node2/'
dst1 = 'e:/destination1'
dst2 = 'e:/destination2'
filename='file.xml'
shutil.copy(os.path.join(src, filename), dst1, dst2)


Please advice?

Kewclassic
kewlclassicAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
kewlclassicConnect With a Mentor Author Commented:
I got it working.
0
 
HiccupZhuCommented:
Try to use this directly,

os.system('cp -rf %s %s' % (src, dst1));
os.system('cp -rf %s %s' % (src, dst2));

If your computer is not command 'cp', you can try install mingw to do this.
0
 
peprCommented:
@kewlclassic: Just write what was the problem and then accept your own answer. This is a good way to close the question.
0
 
kewlclassicAuthor Commented:
I got it working
0
All Courses

From novice to tech pro — start learning today.