Moving a file changes its path and places the file in a different directory. For example, a file located at the path “directory1/file1.txt” can be moved to “directory2/file1.txt”.
Use pathlib.Path.rename() to move a file
- If already using pathlib to work with files, this method can also be used. Renaming the path will move the file to a new directory.
- Further reading: See documentation for pathlib here.