Link to home
Start Free TrialLog in
Avatar of kewlclassic
kewlclassic

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of kewlclassic
kewlclassic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of pepr
pepr

@kewlclassic: Just write what was the problem and then accept your own answer. This is a good way to close the question.
Avatar of kewlclassic

ASKER

I got it working