Q:

Moving multiple file types (*.jpg, *.pdf and *.tiff) to another directory with Python

I'd like to move files with selected formats/types (eg: pdf, jpg and tiff) to another directory. 
Currently, I have this code below that moves ALL files from dir1 and its sub-directories to dir2:
for root, dirs, files in os.walk(dir1, topdown=True):
    for name in files:
        shutil.move(os.path.join(root, name), os.path.join(dir2, name))

But the above codes include all files. 
I just want to move the pdf, tiff and jpg files, and leave all other file formats behind in the original directory. Can anyone help?

A:

Something like this would be the straightforward approach:
for root, dirs, files in os.walk(dir1, topdown=True):
    for name in files:
        if name.endswith(".pdf") or name.endswith(".jpg") or name.endswith(".tiff"): 
            shutil.move(os.path.join(root, name), os.path.join(dir2, name))

