daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest May 16th, 2018 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top