Skip to content

Instantly share code, notes, and snippets.

@liangzr
Created January 23, 2017 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liangzr/55adb245aa5a85785e6164c465e41488 to your computer and use it in GitHub Desktop.
Save liangzr/55adb245aa5a85785e6164c465e41488 to your computer and use it in GitHub Desktop.
install all apks under folder
#! /usr/bin/python
# coding:utf-8
"""update_readme.py: update readme files automatical"""
__author__ = "Jory Liang"
__copyright__ = "Copyright 2015, Tamer"
import os
import re
# 要安装的文件夹
DEFAULT_FOLDER = "."
# 待安装列表
installList = []
# 匹配后缀
p = re.compile(r'^.*\.(\w+?)$')
def install_apk():
print "there are " + str(len(installList)) + " apk files in total, press ENTER to continue."
raw_input()
index = 1
for item in installList:
print 'installing "%s"\r\t\t\t\t\t\t\t\t\t\t\t\t %d/%d' % (item, index, len(installList))
os.system("adb install " + item)
# os.system("rm "+item)
index = index + 1
def scan_folder(root_dir=DEFAULT_FOLDER):
for lists in os.listdir(root_dir):
# 跳过隐藏文件夹
if lists[0] == ".":
continue
path = os.path.join(root_dir, lists)
if os.path.isdir(path):
scan_folder(path)
elif os.path.isfile(path):
handle_files(path)
def handle_files(path):
m = p.findall(path)
if m:
tp = m[0]
if tp == "apk":
# print
print path
installList.append(path)
def main():
print "\n-------------- scan your folder --------------\n"
scan_folder()
print "\n-------------- start installing... --------------\n"
install_apk()
print "\n-------------- Done! --------------\n"
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment