# # Freeman Lo # # Renaming foto files in my foto directory # for ease of generating webpages with embedded # html tags. ;) # # Personal project ########################################### import os import shutil def main(): # instantiate filepath, # Enter your static or dynamic path filepath="C:\\FooBar\\Foto" # instantiate list obj flist=[] # instantiate variables x=0 # Rename this if you want to b/c all of my fotos starts with the word foto fname="foto" # inserting my filepath from a foto directory to the file obj flist = os.listdir(filepath) # loop each of the files in that particular path to copy and rename each foto file accordingly for i in flist: afname = flist[x] src = filepath+"\\"+afname dst = filepath+"\\"+fname+str(x)+".jpg" shutil.copyfile(src,dst) x=x+1 main()