[Tutor] command prompt ??

Daniel Ehrenberg littledanehren at yahoo.com
Wed Dec 3 22:31:30 EST 2003


Jacques  wrote:
> "rename c:\windows\*.pwl
> c:\windows\*.zzz"
> how come that doesn't work wit win xp and command
> prompt?every time i put that in i get "The syntax of
> the command is incorrect."

This isn't really related to Python, but it's probably
because the Windows XP shell was significantly
downgraded from the previous version. I suggest
upgrading to Morphix GNU/Linux.

A python script can probably be created with the same
function. Something like:

import os
files = [x for x in os.listdir('c:\windows\') if
x.endswith('.pwl')]
for some_file in files:
    os.rename(r'c:\windows\'+some_file, 
          r'c:\windows\'+some_file[:-4]+'.zzz')

This is untested, though. Don't blame Python for being
longer for this; shell scripts are always better for
simple, low-level system interaction.

Daniel Ehrenberg

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/



More information about the Tutor mailing list