moving a file in a filesystem-independent way?

Inyeol Lee inyeol.lee at siimage.com
Fri Jan 31 01:13:38 CET 2003


On Thu, Jan 30, 2003 at 07:00:15PM -0500, Francois Pinard wrote:
> [Inyeol Lee]
> 
> > > [...] os.rename(A,B) [...]
> 
> > shutil.move(src, dst), new in 2.3
> 
> Just curious, will it work with directories too?  And with whole directory
> hierarchies when on different filesystems?  I think `mv' has been modified
> recently (all being relative of course!), so it can do the latter thing.

Yes, according to the 2.3a1 library reference;
"""
move(src, dst)
    Recursively move a file or directory to another location. 

    If the destination is on our current filesystem, then simply use rename.
    Otherwise, copy src to the dst and then remove src. 

    New in version 2.3. 
"""

Inyeol...





More information about the Python-list mailing list