blob: efe6c2684f001654c6457fe4c4118024a7091e42 [file] [log] [blame]
Tyler Scott384f37a2016-05-05 16:09:05 -06001"use strict";
2const fs = require('fs');
3
4const regex = /^Original File Name: ([\w\d-]+\.nc)\s*^NDN Name: (\/(?:[\w\d-]+\/)*)/gm;
5
6fs.readFile('sample_output', 'utf8',function(err, data){
7
8 if (err){
9 return console.error(err);
10 }
11
12 var output = {};
13 for (let match = regex.exec(data); match; match = regex.exec(data)){
14 if (output[match[2]]){
15 console.log("Duplicate found for:", match[2], "|", output[match[2]], "|", match[1]);
16 continue;
17 }
18 output[match[2]] = match[1];
19 }
20
21 console.log("Found", Object.keys(output).length, "conversions.");
22
23 fs.writeFile('conversions.json', JSON.stringify(output), function(err){
24 if (err){
25 return console.error(err);
26 }
27 });
28
29});
30