From e7b059f08b29d2606ce1b242ed98be9bfcbef8a3 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 24 May 2022 18:15:03 +0200 Subject: [PATCH] Remove invalid chars from filename also in simple renaming example --- resources/scripts/renamefiles/simple-example.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/scripts/renamefiles/simple-example.js b/resources/scripts/renamefiles/simple-example.js index c11c3ab..77aa111 100644 --- a/resources/scripts/renamefiles/simple-example.js +++ b/resources/scripts/renamefiles/simple-example.js @@ -25,11 +25,12 @@ if (!fileInfo.hasAudioTracks && !fileInfo.hasVideoTracks) { const fieldsToInclude = [tag.albumartist || tag.artist, tag.album, tag.trackPos || infoFromFileName.trackPos, tag.title || infoFromFileName.title] let newName = "" for (let field of fieldsToInclude) { + field = field.toString() if (typeof field === "number" && tag.trackTotal) { - field = field.toString().padStart(tag.trackTotal.toString().length, "0") + field = field.padStart(tag.trackTotal.toString().length, "0") } if (field && field.length !== 0) { - newName = newName.concat(newName.length === 0 ? "" : " - ", field) + newName = newName.concat(newName.length === 0 ? "" : " - ", field.toString().replace(/[\/\\]/gi, " - ").replace(/[<>?!*|:\"\n\f\r]/gi, "")) } } newName = newName.concat(".", fileInfo.suitableSuffix || fileInfo.currentSuffix)