#1 : 25/03-20 20:51 Michel
Posts: 2
|
Hi, I need to rename
from aaaaa_bbbb_ccccc_1581804175_dddd.mp4 to bbbb_2020-01-15_17-02-55_dddd.mp4 to convert the epoch time I use this script https://www.advancedrenamer.com/forum_thread?for um_id=3822 but it only works if the epoch time is the name of the file: "1581804175.mp4" I'm using replace to extract that segment and then apply the script 1. Replace (.*)_(.*)_(.*)_(.*)_(.*) \4 2. Script but I don't know how I can add the other segments. Thanks |
#2 : 26/03-20 00:10 David Lee
Posts: 1125
|
You need to build the regex match into the script.
Try this script: name = item.newBasename.match(/(.*_)(.*_)(.*_)(\d{10})(_.*)/); dat = new Date(1000 * parseInt(name[4])); return name[2] + dat.getFullYear() + "-" + ("0" + dat.getMonth()).slice(-2) + "-" + ("0" + dat.getDate()).slice(-2) + "_" + ("0" + dat.getHours()).slice(-2) + "-" + ("0" + dat.getMinutes()).slice(-2) + "-" + ("0" + dat.getSeconds()).slice(-2) + name[5]; On my PC this returns: bbbb_2020-01-15_22-02-55_dddd.mp4 - so I assume that you must be in timezone UTC-7 |
#3 : 26/03-20 01:00 Michel
Posts: 2
|
Reply to #2:
works perfectly! many thanks. |