From 7856f7fae7f437319d28b27c9fe64125ae84d700 Mon Sep 17 00:00:00 2001 From: mrq Date: Thu, 6 Oct 2022 01:29:38 +0000 Subject: [PATCH] allows for duplicate tag names (such as if you have the same source pic, but cropped differently) --- utils/renamer/preprocess.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/utils/renamer/preprocess.js b/utils/renamer/preprocess.js index 5edacc5..4a95be5 100755 --- a/utils/renamer/preprocess.js +++ b/utils/renamer/preprocess.js @@ -52,9 +52,8 @@ let parse = async () => { let md5 = file.match(/^([a-f0-9]{32})/); if ( !md5 ) continue; md5 = md5[1]; - let ext = file.split(".").pop() - - console.log(`[${100.0 * i / files.length}%]: ${md5}`); + + console.log(`[${(100.0 * i / files.length).toFixed(3)}%]: ${md5}`); let rateLimit = false; if ( !cache[md5] ) { @@ -112,8 +111,6 @@ let parse = async () => { if ( artist ) tags.unshift(artist); if ( content ) tags.unshift(content); - console.log(tags) - let jointmp = ""; let filtered = []; for ( let i in tags ) { @@ -124,7 +121,7 @@ let parse = async () => { let joined = filtered.join(" ") // NOOOOOO YOU'RE SUPPOSE TO DO IT ASYNCHRONOUSLY SO IT'S NOT BLOCKING - require("fs").copyFileSync(`${config.input}/${file}`, `${config.output}/${joined}.${ext}`) + require("fs").copyFileSync(`${config.input}/${file}`, `${config.output}/${file.replace(md5, joined)}`) if ( rateLimit && config.rateLimit ) await new Promise( (resolve) => { setTimeout(resolve, config.rateLimit)