move all files in directory with shutils

Solutions on MaxInterview for move all files in directory with shutils by the best coders in the world

showing results for - "move all files in directory with shutils"
Axel
23 May 2020
1import shutil
2import os
3    
4source_dir = '/path/to/source_folder'
5target_dir = '/path/to/dest_folder'
6    
7file_names = os.listdir(source_dir)
8    
9for file_name in file_names:
10    shutil.move(os.path.join(source_dir, file_name), target_dir)