How to handle spaces in export code

Sorry for the dumb question, but I'm having issues trying to get hard spaces to obey in output.
My code is:
`

$filename(txt,utf-8)
   Sort on Track
   Track  Length                  Bitrate                     BPM             Key                 Filename                                                                                                                                                        

$loop(%track%)  %track% - Length: %_length% secs     Bitrate: $left(%_bitrate%  kbit/s   ,3)     BPM: $left(%bpm%    ,3)     Key: $left(%initialkey%    ,3)	- $left(%_filename_ext%,45)
$loopend()

The results shows the Key column and Filename Column don't print the same length. How do I pad spaces in the function so that they line up properly? Look at tracks 106, 107, 109.

Also, is there a way to total the length field?

   Track  Length                      Bitrate              BPM             Key         - Filename                                                                                                                                                        

  101 - Length: 06:02 secs     Bitrate: 128     BPM: 136     Key: Gm - Lido Shuffle LIve - Boz Scaggs.mp3
  102 - Length: 03:46 secs     Bitrate: 128     BPM: 120     Key: Am - Cold Sweat - Boneshakers.mp3
  103 - Length: 04:30 secs     Bitrate: 192     BPM: 121     Key: Em - Josie - Steely Dan.mp3
  104 - Length: 02:50 secs     Bitrate: 128     BPM: 134     Key: Dm - Get Ready - Rare Earth.mp3
  105 - Length: 04:59 secs     Bitrate: 128     BPM: 109     Key: Fm   - Spooky - Atlanta Rhythm Section.mp3
  106 - Length: 04:30 secs     Bitrate: 128     BPM: 101     Key: E      - Let It Roll - Little Feat.mp3
  107 - Length: 04:42 secs     Bitrate: 176     BPM: 100     Key: Gm - Don't Change Horses - Tower of Power.mp3
  109 - Length: 03:32 secs     Bitrate: 186     BPM: 101     Key: Ebm               - VEHICLE (Live) - The Ides Of March.mp3
  110 - Length: 05:30 secs     Bitrate: 192     BPM: 119     Key: Gm - Sly Medley Mixdown - Gary.mp3
9 songs               40 min 21 sec

Do you really want to get a plain text file with a table in the end?
If this output is to be fed to a formatter that understands tab characters, then use $char(9) as separator between the columns.

If you really need space characters then something like
%initialkey%$repeat( ,$sub(8,$len(%initalkey%))
where "8" is the maximum column width of your choice.
As you have a fair number of text constants in each line (which is why I don't understand why you need column headers and vice versa, if you have column headers why repeat the data descriptor in each line ... but that is up to you), you may calculate the column width either including them or leaving then out.

Another remark:

Such a statement does not make a lot of sense: if you take the 3 leftmost characters from a string like "128 kbit/s " then you end up with just "128" and all the trailing text will be cut off anyway. If you want to get just the number in 3 digits, use $num(%_bitrate%,3) and add the embroidering text then as text constant.

Have a look at the documenation:

and the global variables for export which features among others
%_total_time% Total playing time (formatted output)