?? rename.py
字號:
# -*- coding:gbk -*-
import os, shutil
def renm():
pth = os.path.join( os.path.dirname(__file__) )
cunt = 0
for p in os.listdir( pth ):
if os.path.isdir( p ):
pthwlk = os.walk( p )
for root, dr, fl in pthwlk:
if fl and root != '處理后':
tt = root.split( '\\' )
for f in fl:
fnlst = os.path.splitext( f )
if '.db' not in fnlst:
fn = tt[0] + '_' + fnlst[0].replace(' ', '') + '_' + 'cpy%003d' % int( tt[-1] )
ptmd = os.path.join( pth, '處理后' )
if not os.access( ptmd, os.R_OK ):
print "建立 '處理后' 文件夾"
os.makedirs( ptmd )
fnpth = os.path.join( ptmd, fn + fnlst[1] )
fpth = os.path.join( pth, root, f )
print "原始文件名:", fpth
shutil.copy( fpth, fnpth )
print "重命名后:", fnpth
cunt += int( tt[-1] )
print "作品數量:%d" % cunt
if __name__ == '__main__':
renm()
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -