#-*- conding:utf-8 -*-
import sys, string, os, shutil
def RenameFiles(srcdir):
srcfiles = os.listdir(srcdir)
#print srcfiles
for x in xrange(len(srcfiles)):
#print len(srcfiles)
channel_id=srcfiles[x].split("_")
#print channel_id[1]
#print x
#print srcdir
old_channel_name=os.path.join(srcdir,srcfiles[x])
new_channel_name=os.path.join(srcdir+channel_id[1])
print old_channle_name
print '----------'
print new_channel
os.rename(old_channle_name,new_channel_name)
srcdir = "E:\\3.0.0\\partners_pkg\\partners_pkg\\"
RenameFiles(srcdir)
原先的渠道包为:渠道名_渠道id.apk修改为渠道id.apk
//
方法二:
渠道号6位+“.apk”正好10位
#-*- conding:utf-8 -*-
import sys, string, os, shutil
def RenameFiles(srcdir):
srcfiles = os.listdir(srcdir)
#print srcfiles
for x in xrange(len(srcfiles)):
#print len(srcfiles[x])
if(len(srcfiles[x])==10):
print "file length is 10!"
break
channel_id_apk=srcfiles[x][-10:]
print channel_id_apk
old_channel_name=os.path.join(srcdir,srcfiles[x])
new_channel_name=os.path.join(srcdir+channel_id_apk)
print old_channel_name
print new_channel_name
os.rename(old_channel_name,new_channel_name)
srcdir = "E:\\4.0.0\\partners_pkg\\partners_pkg\\"
RenameFiles(srcdir)