I'm trying to move some files around on my filesystem. I'd like to use Python 3's Pathlib to do so, in particular, Path.rename.
Say I want to move Path('/a/b/c/d') to Path('/w/x/y/z').
Path('/a/b/c/d').rename(Path('/w/x/y/z'))
gives
FileNotFoundError: [Errno 2] No such file or directory: '/a/b/c/d' -> '/w/x/y/z'
I can fix this with
os.makedirs(Path('/w/x/y', exist_ok=True)
Path('/a/b/c/d').rename(Path('/w/x/y/z'))
But that's less elegant than old school os, which has a method called renames which does this for you. Is there a way to do this in Pathlib?