how to get os.system () call to cooperate on Windows

Gabriel Genellina gagsl-py2 at
Wed Oct 28 05:43:21 CET 2009

En Tue, 27 Oct 2009 23:04:47 -0300, Steven D'Aprano  
<steven at> escribió:
> On Tue, 27 Oct 2009 21:48:36 -0300, Gabriel Genellina wrote:
>> En Tue, 27 Oct 2009 10:55:09 -0300, TerryP <bigboss1964 at>
>> escribió:
>>> On Oct 26, 10:00 am, Anthra Norell <anthra.nor... at> wrote:

>>>> How can one copy files on the OS level?
>> from ctypes import windll
>> CopyFile = windll.kernel32.CopyFileA
>> CopyFile("d:\\temp\\old.txt", "d:\\temp\\new.txt", True)
> Have I missed something? What's wrong with shutil?

There's nothing wrong with shutil, but CopyFile and friends have some  
additional features (correct handling of alternate data streams, progress  
callback, reduced disk fragmentation...) that some people may be  
interested in.

The idea was just to show how to call CopyFile using ctypes, not implying  
that it's the only way to do that. Everyone knows that the One and True  
Way of copying files is using PIP.

Gabriel Genellina

More information about the Python-list mailing list