newbie: windows xp scripting

oscartheduck oscartheduck at gmail.com
Sun May 21 12:17:44 EDT 2006


I've been having trouble with the following style of script. It's
simple stuff, I know, but it's stumping me:

import os

dirfrom = 'C:\\test'
dirto = 'C:\\test1\\'

copy_command = 'copy "%s" "%s"' % (dirfrom, dirto)

if os.system(copy_command) == 0:
    print "yay"
else:
    print "boo"


What's going wrong is with the %s substitution part. I've tried more
complex scipts and kept running against an error where my script just
wouldn't work. So I stripped back and back and back to this point,
where I'm just trying to run a simple copy command. But for some
reason, it fails.

If I don't use the %s substitution but use the full pathnames
explicitly in the copy command, it works fine. So that's where my issue
seems to be. Help!




More information about the Python-list mailing list