From b0cd798ec1ccd02a6a01aaf1d68b3dc776226b46 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 25 Nov 2020 01:34:51 +0100 Subject: [PATCH] Make renaming example for lrc files more generic --- resources/scripts/renamefiles/example1.js | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/resources/scripts/renamefiles/example1.js b/resources/scripts/renamefiles/example1.js index d1c9d4a..b51c820 100644 --- a/resources/scripts/renamefiles/example1.js +++ b/resources/scripts/renamefiles/example1.js @@ -96,20 +96,21 @@ if (fileInfo.currentName.indexOf(".") === 0 return } -// treat *.lrc files like their corresponding *.mp3 files -var keepSuffix +// treat *.lrc files like their corresponding audio files +var keepSuffix; if (fileInfo.currentSuffix === "lrc") { - // deduce path of corresponding *.mp3 file - var correspondingMp3File = fileInfo.currentPathWithoutExtension + ".mp3" - // keep the lrc suffix later - keepSuffix = fileInfo.currentSuffix - // use the file info from the corresponding *.mp3 file - fileInfo = tageditor.parseFileInfo(correspondingMp3File) - if (fileInfo.ioErrorOccured) { - tageditor.skip("skipped, " + correspondingMp3File + " not present") - return + keepSuffix = fileInfo.currentSuffix; // keep the lrc suffix later + for(let extension of ["mp3", "flac", "m4a"]) { + fileInfo = tageditor.parseFileInfo(fileInfo.currentPathWithoutExtension + "." + extension); + tag = fileInfo.tag; + if (!fileInfo.ioErrorOccured) { + break; + } + } + if (fileInfo.ioErrorOccured) { + tageditor.skip("skipping, corresponding audio file not present"); + return; } - tag = fileInfo.tag } // skip files which don't contain audio or video tracks