SoFunction
Updated on 2024-11-19

python implementation of a method to rename images in a folder consecutively

A python implementation of a method to rename images in a folder consecutively:

import os

class BatchRename():
 def __init__(self):
   = 'C:/Users/zxl/Desktop/tr'

 def rename(self):
  filelist = ()
  total_num = len(filelist)
  i = 101
  for item in filelist:
   if ('.jpg'):
    src = ((), item)
    dst = ((), str(i) + '.jpg')
    try:
     (src, dst)
     print 'converting %s to %s ...' % (src, dst)
     i = i + 1
    except:
     continue
  print 'total %d to rename & converted %d jpgs' % (total_num, i)

if __name__ == '__main__':
 demo = BatchRename()
 ()

Above this python implementation of continuous renaming of images in the folder method is all that I have shared with you, I hope to be able to give you a reference, and I hope you will support me more.