[Tutor] Renaming directories

Magnus Lyckå magnus@thinkware.se
Wed May 7 07:10:02 2003


At 12:54 2003-05-07 +0200, Charlie Clark wrote:
>The problem is quite simple I need to rename a bunch of files and
>directories. I can do the files using os.path.rename() but this gives an
>error with directories. What are the options? I've done some searching
>already but couldn't find anything suitable.

There is no such thing as os.path.rename that I know of. At least
not in Python 2.2.

os.rename should work though.

 >>> import os
 >>> help(os.rename)
Help on built-in function rename:
rename(...)
     rename(old, new) -> None
     Rename a file or directory.

It works for me. I don't think we can help you unless you
provide more details, such as what OS, what kind of file system
and in particular: What is the error message?

I can imagine that the directory is locked for some reason.


--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program