Skip to content

Commit

Permalink
Remove invalid chars from filename also in simple renaming example
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed May 24, 2022
1 parent 7105d63 commit e7b059f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions resources/scripts/renamefiles/simple-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e7b059f

Please sign in to comment.