python 批量修改文件名代码


下面是python 批量修改文件名代码
view plaincopy to clipboardprint?
#!/usr/bin/env python  
#coding=utf-8  
import os,os.path  
import shutil,string  
dir = C:\test
for i in os.listdir(dir):  
    newfile = i.replace(.,_)  
    oldfullfile = dir \ i  
    newfullfile = dir \ newfile  
    print oldfullfile  
    print newfullfile  
    shutil.move(oldfullfile,newfullfile)  
    print i 

相关内容

    暂无相关文章

评论关闭