how to copy and move file with its attribute?

Nobody nobody at nowhere.com
Mon Jul 19 14:46:55 EDT 2010


On Mon, 19 Jul 2010 17:57:31 +0100, MRAB wrote:

>> About this one. I tried the os.system copy. But it seems I cant find the 
>> right syntax.
>> 
>> *os.system ("xcopy /s %s %s" % (dirname1, dirname2))*
>> 
>> This one seems to not working.
>> 
> In what way doesn't it work?
> 
> If the names contain spaces then you need to quote them:
> 
>      os.system('xcopy /s "%s" "%s"' % (dirname1, dirname2))

No, you need to use subprocess.call() instead of os.system().

If you absolutely must use os.system() for some reason, at least quote the
arguments correctly. If you want to know how to do this, look at the
subprocess.py source code (hint: it's not as simple as the above suggests).





More information about the Python-list mailing list