Directly on the code
↓
1 #! python3 2 # -*- coding: UTF-8 -*- 3 4 import os 5 import time 6 import shutil 7 8 #Windows聚焦图片位置 9 #C:\Users\xxxxxx\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets 10 11 #定义 12 def rename(): 13 #path = r'C:\Users\xxxxxx\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets' 14 #newpath = r'D:\windows_focus'#新的保存路径 15 path = r'C:\Users\xxxxxx\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets' 16 newpath = r'D:\windows_focus\images_'#新的保存路径 17 18 dirtime = time.strftime("%Y%m%d%H%M") 19 20 if not os.path.exists(newpath+dirtime): 21 #os.mkdir(newpath+dirtime) 22 os.makedirs(newpath+dirtime) 23 24 i = 1 25 = the os.listdir Filelist (path) # obtain all files in the folder path 26 is Print ( ' Total: ' + STR (len (Filelist)) + ' files ' ) 27 for Files in Filelist: # across all the files 28 olddir the os.path.join = (path, files) # original file path 29 fileSize = os.path.getsize (olddir) / 1024 30 Print (I, ' [ ' + STR (fileSize) + ' KB] ' , olddir) 31 is 32 Timeline The time.strftime = ( "The Y% m% D%% H% M% S " ) # Get the current time, year, month, day, hour 33 is # Newdir = the os.path.join (newpath is, Timeline + '_' + STR (I) + '. JPG ') 34 is Newdir the os.path.join = (+ newpath is dirtime, Timeline + ' _ ' + STR (I) + ' .jpg ' ) 35 Print ( ' ↓ ' ) 36 37 [ IF fileSize> 150 : 38 is shutil.copyfile (olddir , Newdir) # copies the original file path to the new path 39 Print (I, ' [ ' + STR (fileSize) + 'KB] ' , Newdir, ' file conversion. ' ) 40 the else : 41 is Print (I, ' [ ' + STR (fileSize) + ' KB] ' , Newdir, ' ! File is too small to ignore ' ) 42 is 43 is # note indentation 44 is Pass # Pass is null statement 45 Print ( '' ) 46 is I =. 1 + 47 48 # call 49 the rename ()