[Tutor] simply moving files

Alan Gauld alan.gauld at btinternet.com
Wed May 13 00:27:33 CEST 2009

"Matt Herzog" <msh at blisses.org> wrote

> os.renames happily renames the source directory, but that's not what I 
> want.
> Any other suggestions?

You still haven't said why you can't use shutil.move()

move() uses rename if appropriate or copies/deletes if not.
It makes moving much more reliable and saves you a lot of
extra work checking whether the src and dst are on the same
filesystem etc.

You should justy be abloe to use shutil.move()
What is the probnlem with this (apart from Kent's point that
you were not passing filenames originally!)

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list