Dont Panic


Small Node script for export

11 Jul 2012
I Decided that i wanted to move away from simple note which has served me well for the last few years and instead rely on a notes folder in dropbox and various platform app's to read / write to these Simple Note has various exporting options but one of them is not what i wanted 'all my notes as individual text files' so i exported them as a JSON object and set to work with Node.js SimpleNoteExport.js var fs = require('fs'); var notesString = fs.readFileSync('simplenote_export.json', 'utf8'); var notesArray = JSON.parse(notesString); console.log('you have '+notesArray.length+' notes'); for (var i = notesArray.length - 1; i >= 0; i--) { var filename = notesArray[i].content.substr(0,30) filename = filename.replace(/(\r\n|\n|\r|\/|\\||:)/gm," "); filename = filename.replace(/\s+/g," "); //console.log(filename); var newNote = fs.openSync('result/'+filename+'.txt','w'); fs.writeSync(newNote, notesArray[i].content); };