Skip to content

Instantly share code, notes, and snippets.

@yassineAlouini
Created June 2, 2017 11:43
Show Gist options
  • Save yassineAlouini/07543fa1debe1fb6aae817165c13d31a to your computer and use it in GitHub Desktop.
Save yassineAlouini/07543fa1debe1fb6aae817165c13d31a to your computer and use it in GitHub Desktop.
Compress a list of files using the BZ2 protocol.
import bz2
import glob
for fp in glob.iglob('path/to_files'):
with open(fp, 'rb') as f_input:
with bz2.BZ2File(fp + '.bz2', 'wb', compresslevel=9) as f_output:
f_output.write(f_input.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment