I've been using os.rename to move files in Python. However, it appears that this fails if you try to move files between one mountpoint and another (on Linux).
Is there a Python library or function to move files between mountpoints, similar to mv on Linux?
This is a common caveat with os.rename. The higher level shutil module and it's move method works around this for you by using os.rename() or shutil.copy2() as appropriate.
One thing to keep in mind is that this loses the atomic guarantee that os.rename has if it isn't on the same filesystem.
See https://docs.python.org/2/library/shutil.html#shutil.move
You can use mv using subprocess
from subprocess import check_call
check_call(["mv","src","dest"])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With