[Tutor] File renaming using os.rename problem (spir)

Roy Hinkelman royhink at gmail.com
Tue Dec 8 23:55:13 CET 2009

I got it.

Switched to shutil and made to paths complete paths. The added benefit is
that it didn't trash the original file.

shutil.copy2(_files_to_mod + "\\" + fname, _files_to_mod + "\\" + new_name)


---------- Forwarded message ----------
From: Roy Hinkelman <royhink at gmail.com>
Date: Tue, Dec 8, 2009 at 12:27 PM
Subject: Re: File renaming using os.rename problem (spir)
To: tutor at python.org

Why don't you simply print out fname? This should point you to the error.


I did here:
>         if fname == old_name:
>             print fname # test

and it looks correct.

On an WinXP, should I use shutil instead?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091208/03da68b6/attachment-0001.htm>

More information about the Tutor mailing list