Answers for "how to move files with specific extension python"

1

Python move all files with extension

import os
import shutil
sourcepath='C:/Users/kevinconnell/Desktop/Test_Folder/'
sourcefiles = os.listdir(sourcepath)
destinationpath = 'C:/Users/kevinconnell/Desktop/Test_Folder/Archive'
for file in sourcefiles:
    if file.endswith('.png'):
        shutil.move(os.path.join(sourcepath,file), os.path.join(destinationpath,file))
Posted by: Guest on June-18-2020

Code answers related to "how to move files with specific extension python"

Browse Popular Code Answers by Language