searchfolder_delete.py 619 B

1234567891011121314151617181920
  1. import datetime
  2. import kopano
  3. from MAPI.Tags import PR_CREATION_TIME
  4. for u in kopano.users():
  5. print 'user', u
  6. try:
  7. findroot = u.root.folder('FINDER_ROOT')
  8. except:
  9. print 'ERROR getting findroot, skipping user'
  10. continue
  11. print findroot, findroot.subfolder_count
  12. for sf in findroot.folders():
  13. print sf, sf.entryid, sf.hierarchyid
  14. creation_time = sf.prop(PR_CREATION_TIME).value
  15. print 'created at', creation_time
  16. if creation_time < datetime.datetime.now()-datetime.timedelta(days=30):
  17. print 'DELETING!'
  18. findroot.delete(sf)