Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-04-09
4
Medium Priority
?
228 Views
Last Modified: 2014-04-19
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
Comment
Question by:kewlclassic
  • 2
4 Comments
 

Accepted Solution

by:
kewlclassic earned 0 total points
ID: 39990336
I got it working.
0
 

Expert Comment

by:HiccupZhu
ID: 39990554
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
 
LVL 29

Expert Comment

by:pepr
ID: 39990858
@kewlclassic: Just write what was the problem and then accept your own answer. This is a good way to close the question.
0
 

Author Closing Comment

by:kewlclassic
ID: 40010155
I got it working
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month8 days, 9 hours left to enroll

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question