move file python

# To move a file in Python, use one of the following:
import os
import shutil

os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
shutil.move("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
os.replace("path/to/current/file.foo", "path/to/new/destination/for/file.foo")

# In the first two cases the directory in which the new file
# is being created must already exist.

Here is what the above code is Doing:
1. Importing the os and shutil modules.
2. Renaming a file using the os.rename() method.
3. Moving a file using the shutil.move() method.
4. Replacing a file using the os.replace() method.