Search code examples
javascriptnamespacescharacterfilenamesbatch-rename

how can i make all the filenames the same length by adding spaces to it?


i want to make the filename+spaces=211 characters but the problem is that if the file name characters = 30

i would need 181 spaces

while if file name characters = 80

i would need 131 spaces

i have tried advanced renamer

tags options + spaces .

<Name>                                                                                                                                                                                                                

.. and even this script in the scripts section

var maxLength = 25;
var name = item.name;
var date = app.parseTags("<Year Modified><Month Modified><Day Modified>");
var numSpaces = maxLength - name.length - date.length;
var spaces = "";
for (i = 0; i < numSpaces; i++) spaces += " ";
return name + spaces + date; 

but it give me this error name is not defined in the line 3


Solution

  • the script that works using advanced Renamer

    var maxLength = 222;
    var name = item.name;
    var date = app.parseTags("<Year Modified><Month Modified><Day Modified>");
    var numSpaces = maxLength - name.length - date.length;
    var spaces = "";
    for (i = 0; i < numSpaces; i++) spaces += " ";
    return name + spaces + date;
    

    credits David Lee from advanced Renamer forms