#1 : 12/11-23 15:05 Tucoco
Posts: 7
|
Hi, im back from thread called "help about changing day and hour of thousand of files" https://www.advancedrenamer.com/forum_thread?for um_id=13251
I post here because i cant reply anymore on that old thread. That is the original script you posted: deltaHour = 3; match = item.name.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2})\.(\d{2})\.(\d{2})(.*)/); if (match) { Y = 1*match[1]; M = 1*match[2] - 1; D = 1*match[3]; h = 1*match[4]; m = 1*match[5]; s = 1*match[6]; h += deltaHour; date = new Date(Y, M, D, h, m, s); Y = date.getFullYear(); M = date.getMonth() + 1; D = date.getDate(); h = date.getHours(); m = date.getMinutes(); s = date.getSeconds(); return Y + "-" + ("0" + M).slice(-2)+ "-" + ("0" + D).slice(-2) + " " + ("0" + h).slice(-2) + "." + ("0" + m).slice(-2) + "." + ("0" + s).slice(-2) + match[7]; } I need the script changed to affect the filename in a specific way now, instead of adding 3 hours i need it to substract a second. 2023-01-01 00.00.00 xxxxxxxxxxxxx.jpg -> 2022-12-31 23.59.59 xxxxxxxxxxxxx.jpg |
#2 : 12/11-23 15:09 Tucoco
Posts: 7
|
Reply to #1:
Im sorry, edit seems to be not working correctly and repost the entire thread again in front page. |
#3 : 01/12-23 12:36 Tucoco
Posts: 7
|
Any can help me with that?
|
#4 : 02/12-23 10:02 hanajijang
Posts: 1
|
Reply to #3:
Certainly! If you want to subtract a second from the timestamp in the filename, you can modify the script like this: javascript Copy code deltaSecond = -1; // Change to -1 to subtract a second match = item.name.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2})\.(\d{2})\.(\d{2})(.*)/); if (match) { Y = 1 * match[1]; M = 1 * match[2] - 1; D = 1 * match[3]; h = 1 * match[4]; m = 1 * match[5]; s = 1 * match[6]; // Subtract a second s += deltaSecond; if (s < 0) { m -= 1; s += 60; } date = new Date(Y, M, D, h, m, s); Y = date.getFullYear(); M = date.getMonth() + 1; D = date.getDate(); h = date.getHours(); m = date.getMinutes(); s = date.getSeconds(); return ( Y + "-" + ("0" + M).slice(-2) + "-" + ("0" + D).slice(-2) + " " + ("0" + h).slice(-2) + "." + ("0" + m).slice(-2) + "." + ("0" + s).slice(-2) + match[7] ); } This modification should subtract one second from the original timestamp in the filename. Source: https://geometrydashmeltdown.net/ |
#5 : 04/12-23 03:19 Tucoco
Posts: 7
|
Reply to #4:
Fantastic, thanks a lot. |