Skip to content

Instantly share code, notes, and snippets.

@bpineau
Last active September 11, 2018 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpineau/e5fa915a23c3482232d6d6704da66106 to your computer and use it in GitHub Desktop.
Save bpineau/e5fa915a23c3482232d6d6704da66106 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import sys
from base64 import b64encode
def walk_through_files(path):
for (dirpath, dirnames, filenames) in os.walk(path):
for filename in filenames:
if os.path.isdir("{}/{}".format(dirpath, filename)):
continue
yield dirpath, filename
if __name__ == '__main__':
for dirname, fname in walk_through_files(sys.argv[1]):
with open("{}/{}".format(dirname, fname), "rb") as f:
src = '{"Value":"' + b64encode(f.read()) + '"}'
with open("{}/_{}".format(dirname, fname), "w") as dst:
dst.write(src)
os.remove("{}/{}".format(dirname, fname))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment