# ======= task: Batch rename pictures ======= # ==== ======= tool Python # 1 ===== material stored in a folder at all jpg format picture is ======= # 1 ===== material stored in a excel first column is the name of the desired picture, a column called: value ======= # ==== 2019.09.09 23:19 === ===== contribution ========= # ====== ============ now the let su Start Import os Import AS PD PANDAS class All_Picture_Rename_with_anything (): DEF the __init __ (the Y): Yp of r'D = \. 1 '# picture in D: \ 1 folder DEF begin_rename (X-): file_path the os.listdir = (Xp) Get file # path bb = pd.read_excel ('22 .xlsx ', header = 0, columns = 0) # open excel, excel value of the column is required picture name for i in bb [' value ']: for J in file_path: if j.endswith ( 'jpg.') : # show picture deals with JPG original_name = os.path.join (os.path.abspath (Xp), J) changed_name = os.path.join (os.path.abspath (Xp), '' + I + '.jpg') the try: os.rename (original_name, changed_name) for exchanging name # I + =. 1 the except: Continue Print ( 'rename total of% d'% (len (file_path) )) IF the __name__ == '__main__': HK = All_Picture_Rename_with_anything () HK.begin_rename () # ======================= All That IS === === call me ===== ========= Forrest Gump