Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Created December 8, 2014 21:40
Show Gist options
  • Save sideshowcoder/8e080cb866f535fc8564 to your computer and use it in GitHub Desktop.
Save sideshowcoder/8e080cb866f535fc8564 to your computer and use it in GitHub Desktop.
OneNote to Text files
# Print OneNote to PDF
# Extract Text with
# http://www.extractpdf.com/ and name Main.txt
data = File.read "Main.txt"
data = data.split("\f")
data.each do |el|
next if el.empty?
title, *lines = el.split("\n")
next if title.nil?
filename = title.gsub(/[^0-9A-Za-z.\-]/, '_')
File.open("#{filename}.txt", "w") do |f|
contents = [title] + lines
contents = contents.join("\n")
f.puts contents
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment