move file to folder python code example
Example 1: python move file
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")
Example 2: python how move file to directory
import shutil, os
files = ['file1.txt', 'file2.txt', 'file3.txt']
for f in files:
shutil.move(f, 'dest_folder')
Example 3: python move file
import os, shutil
shutil.move('/some/dir/picture.png', '/another/dir/Pictures/')