retrography
5/31/2016 - 4:49 AM

Exports notes from LetterSpace and imports them into SimpleNote using SimpleNote CLI (sncli)

Exports notes from LetterSpace and imports them into SimpleNote using SimpleNote CLI (sncli)

#!/usr/bin/env ruby

require 'json'

Dir.glob(ARGV).each do |fname|
	note = {}
	note['createdate']=File.ctime(fname).to_f
	note['modifydate']=File.mtime(fname).to_f
	f=File.read(fname)
	note['content']=f.gsub(/(#|@)([0-9a-zA-Z_\-]+)/,'\2')
	note['tags']=f.scan(/(#|@)([0-9a-zA-Z_\-]+)/).map{|t| t.last.downcase}
	note['systemtags']=['markdown']
	title=fname.gsub(/\.[^.]+$/,'')
	File.write(title+".json", note.to_json)
	puts title
	%x( cat "#{title+".json"}" | sncli import - )
	sleep 15
end