SongKong Jaikoz

SongKong and Jaikoz Music Tagger Community Forum

Update filename with duration in minutes'seconds

Hi,

I have customised Filename Masks to rename my music files and one attribute I would like to use is the track length. I have found ‘duration’ that provides the information I require, thought the duration is reported in seconds. However, I would prefer the “minutes’seconds” notation.

Is there a way of doing this or is the duration in seconds the only option I have?

Ps. I am still on version 6.9.5; I checked the docs for the 8.0 version but I can’t fing anything that would help me here.

Thank you.

You can use standard Javascript if you need to do something more complex, so for this problem I just searched in Google for javascript convert seconds into minutes and it came back with https://stackoverflow.com/questions/3733227/javascript-seconds-to-minutes-and-seconds that I used for this answer

From the Edit Filename Mask screen create a Javascript User Defined Function using the Add button that your mask can then use in your mask

function formatDuration(duration)
{   
    // Hours, minutes and seconds
    var hrs = ~~(duration / 3600);
    var mins = ~~((duration % 3600) / 60);
    var secs = ~~duration % 60;

    // Output like "1:01" or "4:03:59" or "123:03:59"
    var ret = "";

    if (hrs > 0) {
        ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
    }

    ret += "" + mins + ":" + (secs < 10 ? "0" : "");
    ret += "" + secs;
    return ret;
}

Can then be used in your mask like

+ formatDuration(duration)

e.g

BTW 6.9.5 is very old version, you are missing out on alot of improvements and fixes, update to 8.0 costs only £10 and would give all updates for the next year.

1 Like

Thank you very much, Paul. :slight_smile:
I didn’t know it was possible to write your own java code here.

And yes, I am using a too old version. I’ve bought the 8.0 Pro; I really like your program a lot.

Kr,
Gerco van der Boon

1 Like