To follow up on the excellent script by Pietro Battiston, if you get a Unicode parsing error like this:
Traceback (most recent call last):
File "/Users/kwisatz/bin/ipynb_output_filter.py", line 33, in <module>
write(json_in, sys.stdout, NO_CONVERT)
File "/Users/kwisatz/anaconda/lib/python2.7/site-packages/IPython/nbformat/__init__.py", line 161, in write
fp.write(s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 11549: ordinal not in range(128)
You can add at the beginning of the script:
reload(sys)
sys.setdefaultencoding('utf8')
And that will solve the issue.