Solved

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

Posted on 2014-04-09
4
214 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
Comment Utility
I got it working.
0
 

Expert Comment

by:HiccupZhu
Comment Utility
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 28

Expert Comment

by:pepr
Comment Utility
@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
Comment Utility
I got it working
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now