notetools/export-wm3/export-wm3.js

27 lines
533 B
JavaScript
Raw Normal View History

2024-04-10 15:17:04 +02:00
var fs = require('fs')
var filePath = process.argv[2];
var fileContent = fs.readFileSync(filePath, 'utf8');
var data = fileContent.split("\n");
var documents = {};
for (var i in data)
{
if (!data[i]) continue;
var file = JSON.parse(data[i]);
if (file.nam && file.txt && !file.del)
{
if (!documents[file.nam] || documents[file.nam].dtm < file.dtm)
{
documents[file.nam] = file;
}
}
}
for (var i in documents)
{
console.log(documents[i].nam);
fs.writeFileSync(documents[i].nam + '.md', documents[i].txt, 'utf8');
}