write it in front.
This is a very simple script, very simple. Why write, because I am to cheat the score.
Application Scenarios
There are a bunch of apk files on the host, sorted by category, now decompile them with Apktool, then store them by category and apk name.
Implement
To use this script, you need to install the Apktool. The comments are very detailed and hope to be useful. Of course, this is implemented in Python, you can also write a shell script.
#!/usr/bin/env python# coding=utf-8 "@author: Chicho@date:2015-01-01@function:use apktool to decompile apk fil Es @rununing: Python python decompileapk.py "import os# apk storage path Apkpath ="/home/chicho/test/apps/"# because the APK storage is categorized by category , so get to each apk storage category Dirlist = Os.listdir (apkpath) # Save path after the APK is deserialized with Apktool outputpath= "/home/chicho/test/apktool_out/" # After you decompile the APK or store them in the original category for I in range (len (dirlist)): # Get each sub-category under the apk folder FileList = Apkpath + dirlist[i] # Get the path for each category Apklist = Os.listdir (filelist) # Gets the APK list under each path Category_output = OutputPath + dirlist[i] # Output Path list if not O S.path.exists (category_output): #如果输出的路径不存在那么就创建一个路径 os.makedirs (category_output) for APK in Apklist:por Tion=os.path.splitext (APK) #将apk文件按照它们的文件名和后缀做一个分割 apkoutpath=os.path.join (category_output,portion[0]) #portion storage stored is the filename of the APK apk=os.path.join (apkpath+dirlist[i],apk) #if not os.path.exists (apkoutpath): # os.makedirs (Apko Utpath) cmd = "Apktool D {0} {1} '. Format (APK, Apkoutpath) # After you decompile the APK, follow the file name in the store os.system (cmd) print "All work done! Happy New year~ "
Batch decompile apk file with Apktool