Behaviour of os.rename()

venutaurus539 at gmail.com venutaurus539 at gmail.com
Wed Mar 11 10:35:51 EDT 2009


On Mar 11, 7:27 pm, Emile van Sebille <em... at fenx.com> wrote:
> venutaurus... at gmail.com wrote:
> > Hello all,
> >             I got a suspicion on the behaviour of os.rename
> > (src,dst).If the src is the path of a file and dst is a new filename
> > this os.rename() function is infact creating a new file with the dst
> > name in the current working directory and leaving the src as it is. Is
> > this the expected behavior? If i want the actual source file in its
> > orignal location to be renamed without doing os.chdir() to that
> > directory, is that possible?
>
> > Ex: if my script ren.py contains the following code:
>
> > os.rename("C:\\Folder1\\Folder2\\file1,file2)
>
> os.rename("C:\\Folder1\\Folder2\\file1","C:\\Folder1\\Folder2\\file2")
>
> Emile

Thank you,
It worked :-)



More information about the Python-list mailing list