OSError: Directory not empty raised, how to fix?
Edit: The right tool is shutil.move
:
shutil.move(path_paths[-1], data_data)
assuming path_paths[-1]
is the absolute directory you want to rename, and data_data
is the absolute directory name you want to rename it to.
The destination directory must not already exist for this to work. The two locations don't need to be on the same filesystem.
Old answer: Use os.renames
instead of os.rename
.
It will recursively create any needed directories.