Removed Logging and sheetname characters
Dealing with Special character in filenames to prevent weird folders in windows
This commit is contained in:
parent
b50e8df69e
commit
32b895a776
9
index.js
9
index.js
@ -38,8 +38,6 @@ const check = new Promise(function (resolve) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
check.then(function () {
|
check.then(function () {
|
||||||
console.log(config.position);
|
|
||||||
//process.exit();
|
|
||||||
console.clear();
|
console.clear();
|
||||||
process.stdout.cursorTo(0, 1);
|
process.stdout.cursorTo(0, 1);
|
||||||
console.log(`Ctrl+C to kill the application.`);
|
console.log(`Ctrl+C to kill the application.`);
|
||||||
@ -51,13 +49,14 @@ check.then(function () {
|
|||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
(async function () {
|
(async function () {
|
||||||
await doc.loadInfo();
|
await doc.loadInfo();
|
||||||
if (!fs.existsSync(`${config.outputFolder}/${doc.title}/`)) {
|
var titleClean = doc.title.replace(/[^a-zA-Z0-9 ]/g, '');
|
||||||
fs.mkdirSync(`${config.outputFolder}/${doc.title}/`, { recursive: true });
|
if (!fs.existsSync(`${config.outputFolder}/${titleClean}/`)) {
|
||||||
|
fs.mkdirSync(`${config.outputFolder}/${titleClean}/`, { recursive: true });
|
||||||
}
|
}
|
||||||
docs.sheets.forEach(function (sheet, s) {
|
docs.sheets.forEach(function (sheet, s) {
|
||||||
(async function () {
|
(async function () {
|
||||||
downloadCSV = await doc.sheetsByTitle[sheet].downloadAsCSV();
|
downloadCSV = await doc.sheetsByTitle[sheet].downloadAsCSV();
|
||||||
fs.writeFile(`${config.outputFolder}/${doc.title}/${sheet}.csv`, downloadCSV, function (err) {
|
fs.writeFile(`${config.outputFolder}/${titleClean}/${sheet.replace(/[^a-zA-Z0-9 ]/g)}.csv`, downloadCSV, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user