批量解压 rar (带密码) -- 自己写的 python 小工具

542 阅读1分钟
import os
import threading 
suffix = '.zip'

def extract(file):
  # os.system("unrar x -y -p'{passwd}'  '{filename}' ".format(passwd='w5GrlKpEXhbO9&utD!6KWWrFKmjI@XW3',filename=it))
  os.system("{exec}  '{filename}' ".format(exec='un'+suffix[1:],filename=it))

def getPaths(path):
  res = os.listdir(path)
  return [ os.path.join(os.getcwd(),it) for it in res if it.endswith(suffix)]

if __name__=='__main__':
  try:
    for it in getPaths('./'):
      print('*****file****',it)
      t1 = threading.Thread(target=extract,args=(it, ))
      t1.start()
      t1.join()
    
  except:
    print ("Error: 无法启动线程")