• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

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
0
kewlclassic
Asked:
kewlclassic
  • 2
1 Solution
 
kewlclassicAuthor 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now