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

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Oct 28 03:04:47 CET 2009


On Tue, 27 Oct 2009 21:48:36 -0300, Gabriel Genellina wrote:

> En Tue, 27 Oct 2009 10:55:09 -0300, TerryP <bigboss1964 at gmail.com>
> escribió:
> 
>> On Oct 26, 10:00 am, Anthra Norell <anthra.nor... at bluewin.ch> wrote:
>>> The function "os.system
>>> ('copy file_name directory_name')" turns out doesn't do anything
>>> except flashing a DOS command window for half a second. So my question
>>> is: How can one copy files on the OS level?

[...]

> It's as simple as this:
> 
>    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? 

shutil.copyfile(source, destination) seems to work for me, even on 
Windows.


-- 
Steven



More information about the Python-list mailing list