Using the JavaScript Date functions in Filename Override

  • I'm using Voukoder Pro 2.0.0 (beta) with Vega Pro 22 on Win 11 Pro

    I've tried to use most of the displayed JavaScript Date functions to construct an output filename but, whenever one is used, Voukoder is unable to start. Is this a bug or a training issue (!)? ${OutputFile.Absolute} etc work fine, it's just these embedded Date() calls.

  • Vouk 23. Dezember 2024 um 13:07

    Hat das Thema freigeschaltet.
    • Offizieller Beitrag

    I'm investigating this now.

    Edit:

    Seems like a permissioning problem:

    This was not working:

    • c:\${(new Date()).getSeconds()}.mp4

    This was working:

    • d:\${(new Date()).getSeconds()}.mp4
    • C:\Users\Daniel\OneDrive - Voukoder\Desktop\${(new Date()).getSeconds()}.mp4

    Just make sure it is a valid absolute file name.

  • Many Thanks for your help...all seems to be working now. Some questions related to this:

    • How much JavaScript can one put in this field? i.e. can I create a single Date instance with "const d = new Date()" and then refer to d.getMonth()?
    • Does this field have a fixed length?

    I'd like to create a mask like <original path><original filename (excl extension)-YYYYMMDDHHMMSS<extension>. I'm almost there with the following, and have worked out that I can add a 1 to getMonth() so that function return 1-12 rather than 0 to 11 etc. and I'm sure I'll be able to prepend a 0 to those values that are less than 10. But that is making it quite difficult to do this in you single row field, so I'm resorting to pasting this part of the JS into the field once tested elsewhere:

    ${OutputFile.Path}\${OutputFile.Name}-${(new Date()).getFullYear()}${((new Date()).getMonth() +1)}${(new Date()).getDate()}${(new Date()).getHours()}${(new Date()).getMinutes()}${(new Date()).getSeconds()}.mp4

    produces:

    • Offizieller Beitrag

    The field has a max. length of 32767 and it has a real JavaScript engine behind so those inputs can be quite complex. But it will get difficult to read and edit in a single line. I might change this to a better editor in a next version.

    What you could write:

    Code
    ${ d = new Date(); OutputFile.Path + '\\' + OutputFile.Name + '-' + d.getFullYear() + (d.getMonth() + 1) + d.getDate() + d.getHours() + d.getMinutes() + d.getSeconds() + OutputFile.Extension; }
  • Happy New Year everyone. In Pro, if anyone wants an output filename in the format:

    original path\original filename-yyyy.mm.dd-hh.mm.ss.original extension

    then the following works on Windows 11. Took me ages to get this to work but the secret is to ensure there are no carriage returns etc in the datetime string and no hidden characters before the starting "${" or after the final "}"

    ${
    d = new Date();
    p = /^[0-9]$/;
    s1 = '-';
    s2 = '.';
    datetime = d.getFullYear().toString() + s2 + (d.getMonth() + 1).toString().replace(p,'0' + (d.getMonth() + 1).toString()) + s2 + d.getDate().toString().replace(p,'0' + d.getDate().toString()) + s1 + d.getHours().toString().replace(p,'0' + d.getHours().toString()) + s2 + d.getMinutes().toString().replace(p,'0' + d.getMinutes().toString()) + s2 + d.getSeconds().toString().replace(p,'0' + d.getSeconds().toString());

    OutputFile.Path + '\\' + OutputFile.Name + s1 + datetime + OutputFile.Extension;
    }