|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
const os = require("os");
|
|
|
|
|
const chalk = require("chalk");
|
|
|
|
|
const path = require("path");
|
|
|
|
|
|
|
|
|
@ -15,11 +16,46 @@ if (process.argv[2] == null) {
|
|
|
|
|
|
|
|
|
|
let parsedPath = path.parse(absolutePath);
|
|
|
|
|
delete parsedPath.base;
|
|
|
|
|
parsedPath.name += "-fixed";
|
|
|
|
|
parsedPath.name += "-fixed2";
|
|
|
|
|
|
|
|
|
|
let fixedContents = contents.replace(/(^|\r\n-\r\n)ABNANL2A\r\n940\r\nABNANL2A\r\n/g, "$1");
|
|
|
|
|
let fixedFilename = path.format(parsedPath);
|
|
|
|
|
|
|
|
|
|
let lines = fixedContents.split(/\r?\n/);
|
|
|
|
|
let outputLines = [];
|
|
|
|
|
for (let i=0; i<lines.length; i++) {
|
|
|
|
|
let line = lines[i];
|
|
|
|
|
if (line.startsWith(":86:")) { // contents start
|
|
|
|
|
let desc = line;
|
|
|
|
|
while (!lines[i+1].startsWith(":")) {
|
|
|
|
|
desc += lines[i+1];
|
|
|
|
|
i += 1;
|
|
|
|
|
}
|
|
|
|
|
let replacements = [
|
|
|
|
|
"SEPA OVERBOEKING",
|
|
|
|
|
"SEPA PERIODIEKE OVERB.",
|
|
|
|
|
"IBAN: ",
|
|
|
|
|
"NAAM:",
|
|
|
|
|
"/TRTP/IBAN/",
|
|
|
|
|
/\/TRTP\/.+\/IBAN\//,
|
|
|
|
|
/\/BIC\/\w+\//,
|
|
|
|
|
/NAME\//,
|
|
|
|
|
/\/REMI\//,
|
|
|
|
|
/KENMERK: \w+/,
|
|
|
|
|
/BIC: \w+ /,
|
|
|
|
|
/ +(?= )/g // remove multiple spaces
|
|
|
|
|
]
|
|
|
|
|
replacements.forEach((repl) => {
|
|
|
|
|
desc = desc.replace(repl,' ');
|
|
|
|
|
})
|
|
|
|
|
desc = desc.replace("OMSCHRIJVING:",",");
|
|
|
|
|
outputLines.push(desc);
|
|
|
|
|
} else {
|
|
|
|
|
outputLines.push(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fixedContents = outputLines.join(os.EOL);
|
|
|
|
|
|
|
|
|
|
fs.writeFileSync(fixedFilename, fixedContents, { encoding: "utf8" })
|
|
|
|
|
|
|
|
|
|
console.log(file, "->", fixedFilename);
|
|
|
|
|