$ cat filter.py import os import sys from os import walk from os import listdir import glob from shutil import copy2 mypath = './' dst = './test' #jpgs = glob.glob(os.path.join(mypath, '*.jpg')) #print(jpgs) for f in listdir(mypath): if f.endswith("jpg"): print(f) copy2(f,dst) j = f.replace("jpg","json") print(j) copy2(j,dst)