At work, there is a situation where some apk packages are often sent by the marketing department.
But asked to change the name, too many files, there is no way, only to find ways, fortunately the name is a regular
For example
yzloan-gdtyyb-v2.23.apk--------->yzloan_relase_gdtyyb.apk
Change to this form
#!/usr/bin/env python
#-*-Coding:utf-8-*-
# @Time: 2016/7/20 11:42
# @Author: Big_bao
Import OS
Import Sys
def Rename (args):
#def Rename (args= '/root/python/python_day_practice/720/tuiguangbao/'):
Files=os.listdir (args)
For File in Files:
L = File.split ('-')
A = l[0]+ ' _relase_ ' +l[1]+ ' apk '
Print (file+ '---+a)
Os.rename (Args+file,args+a)
filename = raw_input ("Please input your filename:")
Rename (filename);
Execute Python file
Reference article:
http://blog.csdn.net/fengyu09/article/details/17843119
Http://jingyan.baidu.com/article/fb48e8be37b6696e622e14db.html
Python Bulk Change file name