Guest User

Untitled

a guest
May 16th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import glob, shutil, os, zipfile
  2.  
  3. dates=set()
  4. fromdir="pix"
  5. todir="camarchiv"
  6.  
  7. dates=set()
  8. for file in glob.glob(fromdir+"/*.jpg"):
  9. date = file[9+len(fromdir)+1:9+len(fromdir)+1+10] #snapshot- = 9, / = 1, yyyy-mm-dd = 10
  10. dates.add(date)
  11. today=datetime.date.fromtimestamp(time.time()).strftime("%Y-%m-%d")
  12. if today in dates:
  13. dates.remove(today)
  14.  
  15. for date in dates:
  16. files = glob.glob(fromdir+"/*"+date+"*.jpg")
  17. zip=zipfile.ZipFile("zips/"+date+".zip", "w")
  18. for file in files:
  19. zip.write(file, os.path.basename(file), zipfile.ZIP_DEFLATED)
  20. zip.close()
  21. for file in files:
  22. os.unlink(file)
Add Comment
Please, Sign In to add comment