1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import os
class BatchRename():
def __init__( self ):
self .path = 'C:/Users/zxl/Desktop/tr'
def rename( self ):
filelist = os.listdir( self .path)
total_num = len (filelist)
i = 101
for item in filelist:
if item.endswith( '.jpg' ):
src = os.path.join(os.path.abspath( self .path), item)
dst = os.path.join(os.path.abspath( self .path), str (i) + '.jpg' )
try :
os.rename(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()
demo.rename()
|
以上这篇python 实现对文件夹中的图像连续重命名方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/u010682375/article/details/77161688