Last active
September 11, 2018 20:16
-
-
Save bpineau/e5fa915a23c3482232d6d6704da66106 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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