pad filenames with spaces


#1

All my files have good ID tags but they are sorted into folders for the artitst so the filenames are just the titles of the songs.

But in order to format the filenames for my car I need to pad them with spaces at the end to push out the .mp3 to exactly 24 characters so it doesn't show on the screen.

I know how to add a fixed number of spaces to the end of all the songs, but I want all the filenames the same length...24 characters and since the song titles all have different lengths that means I need to add a different number of spaces to each file to get it to 24.

So, for example I want the files to go from this:

Imagine.mp3
Take Me To The Pilot.mp3

to This:

Imagine_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .mp3
Take Me To The Pilot
_ _ _.mp3

They don't line up because of the different spacing in this forum but they are the same number of characters. In the example, the _ 's represent blank spaces (ignore the spaces between the lines, I needed to put them there so it wouldn't look like a single line).

What I mean is: "Imagine" is 7 characters and to make the filename 24 characters you need to add 17 spaces. "Take me to the Pilot" is 20 characters so you only need to add 4 spaces to make the filename total 24 characters.

Are there any wildcard characters that will create filenames all the same length but leave any characters in the beginning alone?

Thanks for any advice.
JDP


#2

I'm afraid you can't do it at the moment since there is no function for inserting a character X number of times.
For determining the number of spaces to add, you could use the following:

$sub($len(%_filename%),24)


#3

You can use Filename-Filename Converter (ALT+3) with

Mask: %1
Formatstring: $left(%1                        , 24)

There are 24 spaces after %1 in formatstring so it wil add them to filename and then use first 24 characters as new filename.
You can add conditional testing if the length of filename > 24 to leave filename unchanged for long filenames.

Regards
nickless


#4
QUOTE (nickless @ Jul 29 2005, 13:21)
You can use Filename-Filename Converter (ALT+3) with
Mask: %1
Formatstring: $left(%1                        , 24)

There are 24 spaces after %1 in formatstring so it wil add them to filename and then use first 24 characters as new filename.
You can add conditional testing if the length of filename > 24 to leave filename unchanged for long filenames.

Regards
nickless

<{POST_SNAPBACK}>

Thanks for the help guys. nickless's code did the trick! Very cool. This program is unbelievable. I really appreciate the input.

Regards,
JDP


#5

nickless, thanks for your help!

It's a great idea :slight_smile:

Best regards,
~ Florian