问题:

下载的迅雷文件名不顺眼,批量修改下文件名,写了个很简单的重命名的python脚本re_name.py,很方便。

修改前:

修改后:

 

 
  
  1. #!\usr\bin\env python 
  2. # -*- coding: utf-8 -*- 
  3. #Filename:re_name.py  
  4.  
  5. import os 
  6.      
  7. path = os.getcwd() 
  8. for file in os.listdir(path):  
  9.     if file.split('.',)[-1] != 'py'
  10.         index1 = '[迅雷免费高清下载].' 
  11.         index2 = '__480P标清' 
  12.         f1 = file.split(index1,)[1
  13.         f2 = f1.split(index2,) 
  14.         newfile = f2[0] + f2[1
  15.         os.rename(file,newfile)