I'm trying to find python code to transfer the last 10 or so images to another file.
import os
import shutil
import fnmatch
source = 'the folder name'
destination = 'folder name'
def get_latest_image(source, y=('jpg')):
valid_files = [os.path.join(source, destination) for destination in os.listdir(source)]
valid_files = [f for f in valid_files if '.' in f and \
f.rsplit('.',1)[-1] in y and os.path.isfile(f)]
for f in files:
if fnmatch.fnmatch(f,y)==True:
shutil.move(source + f, y + f)
... This is the code I tried using if you could possibly help me figuring out the code it would really help