Guest User

Untitled

a guest
Feb 19th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import os
  3. import zipfile
  4.  
  5. FOLDERS_TO_EXCLUDE = ['Applications', 'Downloads', 'Movies', 'Music', 'Public', 'node_modules']
  6.  
  7. def zipdir(path, ziph):
  8. for root, dirs, files in os.walk(path):
  9. dirs[:] = [x for x in dirs if (
  10. x not in FOLDERS_TO_EXCLUDE) and (not x.startswith('.'))]
  11. for file in files:
  12. if not file.startswith('.'):
  13. ziph.write(os.path.join(root, file))
  14.  
  15. ziph.write('/Users/denizozger/Library/Application Support/Code/User/settings.json')
  16. ziph.write('/Users/denizozger/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings')
  17. ziph.write('/Users/denizozger/.bash_profile')
  18.  
  19. if __name__ == '__main__':
  20. zipf = zipfile.ZipFile('deniz_backup.zip', 'w', zipfile.ZIP_DEFLATED)
  21. zipdir('/Users/denizozger', zipf)
  22. zipf.close()
Add Comment
Please, Sign In to add comment