Rename Image with Week Number?

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Rename Image with Week Number?

Postby socra » Mon Apr 12, 2021 4:08 am

Can BRU rename a file including the week number from EXIF data?
socra
 
Posts: 1
Joined: Mon Apr 12, 2021 4:05 am

Re: Rename Image with Week Number?

Postby Admin » Mon Apr 12, 2021 5:48 am

Yes, using Javascript renaming in BRU:

Code: Select all
function ISO8601_week_no(dt)
  {
     var tdt = new Date(dt.valueOf());
     var dayn = (dt.getDay() + 6) % 7;
     tdt.setDate(tdt.getDate() - dayn + 3);
     var firstThursday = tdt.valueOf();
     tdt.setMonth(0, 1);
     if (tdt.getDay() !== 4)
       {
      tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7);
        }
     return 1 + Math.ceil((firstThursday - tdt) / 604800000);
}

dt = object("modified")
newName = ISO8601_week_no(dt);


Use
dt = exif("taken") instead of dt = object("modified") to use exif taken date instead of modified timestamp.
Admin
Site Admin
 
Posts: 2662
Joined: Tue Mar 08, 2005 8:39 pm


Return to Javascript Renaming