It is a tedious step to change the format of multiple apk format files into a ZIP package at work. Using a Python script and customizing the right-click Run. py file to bring great convenience to the job, here is a simple introduction:
Pre-conditions:
To modify the APK package name: xxxx_cn.apk;
Modified ZIP package name: Cn.zip;
Before the operation of the batch modified APK file into the same folder, and the following written. py script files are also put in the inside.
Python code:
import os #导入os系统命令格式format = ' zip ' #自定义要修改的文件格式filenames =os.listdir (OS.GETCWD ()) #进入当前目录, and define the files in the current directory as Filenamesfor filename in filenames: #对每一个文件进行遍历操作 i=filename.split ('. ') #用 '. ' As a separator, separate if filename!= ' change to zip.py ' from the file name characters and i[-1]!= format: #由于在操作中要把. py file to the file directory you want to modify, so filter the. py file do not do this format operation, with If the file suffix is. zip also do not modify t=filename.split ('_') #再一次对文件进行The key character is ' _ ' os.rename (filename,t[0]+ '. ') +format) #重命名文件
In this way, all the apk files placed in the target folder will be modified to the ZIP format. In the future if there are new APK package to be modified, do not clean the target file existing Zip package, directly pull the modified file to the target directory to repeat the above operation.
It is important to note, however, that running the. py file is performed in the terminal input Python xxx.py (the default Linux installation Python plugin). Of course, in a Linux system you can customize the right-click shortcut to run directly. py file, here is not a cumbersome introduction, you can see another blogger on the Linux system to customize the shortcut key article.
Python bulk Modify file format