Python provides multiple ways to move a file to another directory. You can use the following methods:
import os import shutil os.rename("path/to/file.docx", "new/destination/file.docx") shutil.move("path/to/file.docx", "new/destination/file.docx")
Note: You must include the filename(file.docx
) in both the source and destination arguments. If the filename is changed, then the file will be renamed as well as moved.