0x00. Python 版:
#coding:utf-8
import os
import re
#遍历出已连接设备id
def find_devices():
rst = os.popen('adb devices').read()
devices = re.findall(r'(.*?)\s+device',rst)
if len(devices) > 1:
Ids = devices[1:]
else:
Ids = []
return Ids
# 遍历出待安装的apk
def find_apks():
apks = []
for c in os.listdir(os.getcwd()):
if os.path.isfile(c) and c.endswith('.apk'):
apks.append(c)
return apks
# 安装: adb -s {id} install -r {apk0,apk1,apk2,...}
def main():
apks = find_apks()
devices = find_devices()
if len(apks) != 0:
for id in devices:
for apk in apks:
try:
print '================',id,'========================='
print '[INFO]Apk: ',apk,'...'
print '++++++++++++++++++++++++++++++++++++++++++'
os.system('adb -s ' + id + ' install -r ' + apk)
except:
pass
else:
print 'No apk found'
if __name__ == '__main__':
main()
Windows 批处理版:
@echo off
echo.----------------------------------------------
for /f "skip=1" %%d in ('adb devices -l') do (
echo.正在给设备%%d安装apk:
echo.----------------------------------------------
for /f "delims=" %%a in ('dir /b *.apk') do (
color 0C
echo.正在安装%%a应用到设备%%d ...
adb -s %%d install -r %~dp0%%a
echo.----------------------------------------------
)
)
echo.----------------------------------------------
pause
源文件,飞机:链接: http://pan.baidu.com/s/1qYMsRvQ 密码: dvmv
之后有时间再出其他版本!