安装当前目录下所有apk的脚本
2406 点击·0 回帖
![]() | ![]() | |
![]() | 今天要安装几十个apk,就写了个脚本,递归查找当前目录下所有的apk文件,找到一个安装一个。 安装环境:ubuntu10.04LTS + python2.6.5 1. 打开Android设备“USB调试” 2. 重启ADB: $sudo adb kill-server $sudo adb start-server 3写脚本findAndInstall.py: [python] #-*- coding: cp936 -*- ''''' search apk and install under current folder and sub-folders PythonVersion: 2.6 ''' __author__ = "Herbert dai wen yuan" __version__ = "$Revision: 1.0 $" __date__ = "$Date: 2012-4-24$" __copyright__ = "Copyright (c) 2012 HowFun" __license__ = "Python 2.x" import os PATH = "./" def findToInstall(filePath, level): for item in os.listdir(filePath): print(item + '\n'); curItem = filePath + '/' + item if os.path.isdir(curItem): print("Enter folder: " + curItem); findToInstall(curItem, level + 1) elif os.path.isfile(curItem): if (".apk" == os.path.splitext(item)[1]): print("installing " + item + "......"); os.system("sudo adb install " + curItem.replace(" ", "\ ")); if __name__ == "__main__": print ("Start install>>>>>>>>>>>>>>>>>>>\n"); findToInstall(PATH, 0) print ("Install Finished>>>>>>>>>>>>>>>>>>>\n"); 4.运行脚本:$sudo python findAndInstall.py | |
![]() | ![]() |