tar.py 758 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @Author : liuyuqi
  5. @Contact : liuyuqi.gov@msn.cn
  6. @Time : 2019/11/11 20:18:09
  7. @Version : 1.0
  8. @License : (C)Copyright 2019
  9. @Desc : 200个文件夹打包一次
  10. '''
  11. import os
  12. rootPath = r"/home/twtech/github/python/crawl-mrdx/data"
  13. size = 3
  14. count = 1
  15. count2 = 1
  16. currentDir=""
  17. for path in os.listdir(rootPath):
  18. if os.path.isdir(os.path.join(rootPath,path)):
  19. currentDir = currentDir + " " + path
  20. if count % size == 0:
  21. shellStr = "tar -zcf /ossfs/crawl-mrdx/mrdx%s.tar.gz" % (
  22. count2) + currentDir
  23. os.system(shellStr)
  24. # print(shellStr)
  25. currentDir=""
  26. count2 = count2 + 1
  27. count = count + 1