Created
August 1, 2013 19:41
-
-
Save evernotegists/6134552 to your computer and use it in GitHub Desktop.
Convert base64-encoded data from an exported Evernote note back to its original form.
This file contains hidden or 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 | |
# Copyright 2013 Evernote Corporation. All rights reserved. | |
import base64 | |
import sys | |
# Copy the base64 string from the ENEX file and put it into a file | |
# Pipe base64-encoded data to STDIN | |
data = sys.stdin.read() | |
# Decode data | |
try: | |
imgraw = base64.b64decode(data) | |
except TypeError, te: | |
print 'TypeError: ', te | |
raise SystemExit | |
# Write it to the file passed as a param | |
with file(sys.argv[1], 'wb') as outfile: | |
outfile.write(imgraw) | |
## Usage: | |
## (Change myfile.ext to the desired filename and correct extension) | |
# cat base64File | python b64dec.py myfile.ext | |
## or, if you base64 data is in the pasteboard on a Mac: | |
# pbpaste | python b64dec.py myfile.ext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment