# How to align track length during nfo export

**URL:** https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858
**Category:** Export
**Created:** [August 29, 2009, 7:23pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858 "2009-08-29T19:23:03Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![thetie](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@thetie](https://community.mp3tag.de/u/thetie)
#### Post date: [August 29, 2009, 7:23pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/1 "2009-08-29T19:23:03Z")

</div>

Hi, if anyone could help me with this little coding problem Id be extremly greatful...

When exporting to nfo Id like the track length info (%\_length%) to be alligned vertically.

Ive been looking into how Dano does this in his nfo code, but i cant figure it out. Dano's script lacks artist info (there is only "track no. - track title - track length"). I really need artist (%artist%) to be included since I have alot of VA albums.

This is the standard code i use: (Currently I always need to manually allign all the %\_length% after export...)

```
$loop(%_path%)%track%. %artist% - %title% %_length%
$loopend()

```

This is how i want it to look:

```
Tracklisting: Time:
01. Artist A - Track A 01:00
02. Artist B - Track B 02:37
03. Artist C - Track C 05:26
04. Artist D - Track D 05:31
05. Artist E - Track E 02:58
06. Artist F - Track F 07:31
07. Artist G - Track G 03:30
08. Artist H - Track H 07:40

                                           Total: 00:42:31

```

Thanks for any help! (sorry for my lack of knowledge how to do this)

---

<div class="post-metadata">

### Author: ![newser](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/n/b9bd4f/32.png) [@newser](https://community.mp3tag.de/u/newser)
#### Post date: [August 29, 2009, 8:03pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/2 "2009-08-29T20:03:11Z")

</div>

Try this:

```
$loop(%_path%)%track%. %artist% - %title%$repeat( ,$sub(60,$len(%artist% - %title%)))%_length%
$loopend()
```

---

<div class="post-metadata">

### Author: ![thetie](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@thetie](https://community.mp3tag.de/u/thetie)
#### Post date: [August 29, 2009, 8:18pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/3 "2009-08-29T20:18:05Z")

</div>

Ah! Thx a million! 😃

---

<div class="post-metadata">

### Author: ![thetie](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@thetie](https://community.mp3tag.de/u/thetie)
#### Post date: [August 29, 2009, 11:04pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/4 "2009-08-29T23:04:47Z")

</div>

Sorry if Im pushing my luck here (please forgive me)...  
but is it possible to add a line break when the number of character in %artist% plus %title% reaches the defined placement of %\_length%? So that the rest of the track title continues on the next line?

(On second thought that probably would be difficult, both because it would need the the correct spacing on next line as well as track title needs to break at a whole word not just the number of characters that reaches the limit...) Is it possible? :S

```
Tracklisting: Time:
01. Artist A - Track A 01:00
02. Artist B - Track B with a Really Really Really 02:37
     Long Track Name
03. Artist C - Track C 05:26
```

---

<div class="post-metadata">

### Author: ![newser](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/n/b9bd4f/32.png) [@newser](https://community.mp3tag.de/u/newser)
#### Post date: [August 30, 2009, 5:43am UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/5 "2009-08-30T05:43:56Z")

</div>

v1:

```
$loop(%_path%)$num(%track%,2). $left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60))))
     $mid(%artist% - %title%,61,60) $repeat( ,$sub(60,$len($mid(%artist% - %title%,61,60))))
$loopend()

```

v2 (No empty lines):

```
$loop(%_path%)$loop(%_path%)$num(%track%,2). $iflonger(%artist% - %title%,60,$left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60))))
     $mid(%artist% - %title%,61,60) $repeat( ,$sub(60,$len($mid(%artist% - %title%,61,60)))),$left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60)))))
$loopend()
```

---

<div class="post-metadata">

### Author: ![thetie](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@thetie](https://community.mp3tag.de/u/thetie)
#### Post date: [August 30, 2009, 8:45am UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/6 "2009-08-30T08:45:42Z")

</div>

Wow thank you 🙂

One problem though, i get non-matching no. of loop/loopends on both versions...

I just cannot get my head around how to close them. Final help? 🙂

---

<div class="post-metadata">

### Author: ![newser](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/n/b9bd4f/32.png) [@newser](https://community.mp3tag.de/u/newser)
#### Post date: [August 30, 2009, 10:40am UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/7 "2009-08-30T10:40:52Z")

</div>

Sorry. Now it should work.

v1:

```
$loop(%_path%)$num(%track%,2). $left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60))))%_length%
     $mid(%artist% - %title%,61,60) $repeat( ,$sub(60,$len($mid(%artist% - %title%,61,60))))
$loopend()

```

v2 (No empty lines):

```
$loop(%_path%)$num(%track%,2). $iflonger(%artist% - %title%,60,$left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60))))%_length%
     $mid(%artist% - %title%,61,60) $repeat( ,$sub(60,$len($mid(%artist% - %title%,61,60)))),$left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60))))%_length%)
$loopend()
```

---

<div class="post-metadata">

### Author: ![thetie](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@thetie](https://community.mp3tag.de/u/thetie)
#### Post date: [August 30, 2009, 11:19am UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/8 "2009-08-30T11:19:50Z")

</div>

Perfect!!! Thank you so much newser! 🙂 🙂 This will same me so much time in the future! Thank you again!

---

<div class="post-metadata">

### Author: ![Painorozi](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/8baadc/32.png) [@Painorozi](https://community.mp3tag.de/u/Painorozi)
#### Post date: [November 22, 2010, 10:00pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/9 "2010-11-22T22:00:07Z")

</div>

![:book:](https://community.mp3tag.de/uploads/default/original/1X/0036d5b68f6226c53f6c68abfd0a7b8096fd4505.gif ":book:") ![:book:](https://community.mp3tag.de/uploads/default/original/1X/0036d5b68f6226c53f6c68abfd0a7b8096fd4505.gif ":book:")

Thank you so much ![:rolleyes:](https://community.mp3tag.de/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif ":rolleyes:") 😆

---

<div class="post-metadata">

### Author: ![KrissO](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/96bed5/32.png) [@KrissO](https://community.mp3tag.de/u/KrissO)
#### Post date: [December 9, 2015, 11:33pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/10 "2015-12-09T23:33:33Z")

</div>

Replying to an old topic here.

Does anyone know how I can align the %\_total\_time% with the individual track %\_length%'s? That wasn't included in the code above.

And a second question, how can I remove leading zeros from %\_length% and %\_total\_time%?  
e.g. 00:05:23 -\> 5:23 or 01:19:59 -\> 1:19:59

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [December 10, 2015, 4:35pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/11 "2015-12-10T16:35:19Z")

</div>

> [@KrissO](#):
>
> ... how can I remove leading zeros from %\_length% and %\_total\_time%? e.g. 00:05:23 -\> 5:23 or 01:19:59 -\> 1:19:59

**'00:05:23' ==\> $trimLeft('00:05:23','0:') ==\> '5:23' '01:19:59' ==\> $trimLeft('01:19:59','0:') ==\> '1:19:59'**

DD.20151210.1835.CET

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [December 10, 2015, 5:00pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/12 "2015-12-10T17:00:06Z")

</div>

> [@KrissO](#):
>
> ... how I can align the %\_total\_time% with the individual track %\_length%'s? ...

right aligned ...

**'--\>'$right($repeat($char(32),$len(%\_total\_time%))%\_length%,$len(%\_total\_time%))'\<--' '--\>'$right($repeat($char(32),$len(%\_total\_time%))%\_total\_time%,$len(%\_total\_time%))'\<--'**

**--\> 00:01\<--  
--\>00:00:01\<--**

DD.20151210.1904.CET

---

<div class="post-metadata">

### Author: ![tor11](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tor11](https://community.mp3tag.de/u/tor11)
#### Post date: [January 21, 2025, 5:14pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/13 "2025-01-21T17:14:47Z")

</div>

> v2 (No empty lines):

```auto
$loop(%_path%)$num(%track%,2). $iflonger(%artist% - %title%,60,$left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60))))%_length%
     $mid(%artist% - %title%,61,60) $repeat( ,$sub(60,$len($mid(%artist% - %title%,61,60)))),$left(%artist% - %title%,60) $repeat( ,$sub(60,$len($left(%artist% - %title%,60))))%_length%)
$loopend()

```

This is nice. Is it somehow possible to prevent splitting of words, so it breaks to a new line only with a whole word?

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 21, 2025, 5:30pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/14 "2025-01-21T17:30:22Z")

</div>

Do you mean instead of

```auto
01. Joseph Haydn - Symphony No. 1 in D Major, Hob. I:1: I. Prest 05:07
     o                                                             
02. Joseph Haydn - Symphony No. 1 in D Major, Hob. I:1: II. Anda 06:03
     nte                                                           
03. Joseph Haydn - Symphony No. 1 in D Major, Hob. I:1: III. Pre 02:19
     sto                                                           
04. Joseph Haydn - Symphony No. 2 in C Major, Hob. I:2: I. Alleg 03:21
     ro                                                            
05. Joseph Haydn - Symphony No. 2 in C Major, Hob. I:2: II. Anda 03:03
     nte                                                           
06. Joseph Haydn - Symphony No. 2 in C Major, Hob. I:2: III. Fin 03:11
     ale: Presto

```

you would like to see it like this:

```auto
01. Joseph Haydn - Symphony No. 1 in D Major, Hob. I:1: I. 05:07
     Presto                                                             
02. Joseph Haydn - Symphony No. 1 in D Major, Hob. I:1: II. 06:03
     Andante                                                           
03. Joseph Haydn - Symphony No. 1 in D Major, Hob. I:1: III. 02:19
     Presto                                                           
04. Joseph Haydn - Symphony No. 2 in C Major, Hob. I:2: I. 03:21
     Allegro                                                            
05. Joseph Haydn - Symphony No. 2 in C Major, Hob. I:2: II. 03:03
     Andante                                                           
06. Joseph Haydn - Symphony No. 2 in C Major, Hob. I:2: III. 03:11
     Finale: Presto

```

That would be very difficult 😉

---

<div class="post-metadata">

### Author: ![tor11](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tor11](https://community.mp3tag.de/u/tor11)
#### Post date: [January 21, 2025, 5:32pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/15 "2025-01-21T17:32:23Z")

</div>

Yes, it is a minor detail. But Mp3tag can do wonders, so no harm in asking 🙂

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 21, 2025, 5:34pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/16 "2025-01-21T17:34:59Z")

</div>

What would you do with extra long TITLEs like

```auto
01. Joseph Haydn - Die sieben letzten Worte unseres Erlösers am 06:34
     Kreuze, Hob XX:2: L' Introduzione                             
02. Joseph Haydn - Die sieben letzten Worte unseres Erlösers am 07:01
     Kreuze, Hob XX:2: Sonata I: Pater, dimitte illis, quia nesci  
03. Joseph Haydn - Die sieben letzten Worte unseres Erlösers am 06:43
     Kreuze, Hob XX:2: Sonata II. Hodie mecum eris in Paradiso     
04. Joseph Haydn - Die sieben letzten Worte unseres Erlösers am 07:26
     Kreuze, Hob XX:2: Sonata III. Mulier, ecce filius tuus        
05. Joseph Haydn - Die sieben letzten Worte unseres Erlösers am 05:50
     Kreuze, Hob XX:2: Sonata IV. Deus meus, ut quid derelquisti   

```

---

<div class="post-metadata">

### Author: ![tor11](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tor11](https://community.mp3tag.de/u/tor11)
#### Post date: [February 9, 2025, 4:23pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/17 "2025-02-09T16:23:49Z")

</div>

```auto
$loop(%_path%)$num(%track%,2). $iflonger(%artist% - %title%,60,$left(%artist% - %title%,$strrchr($left(%artist% - %title%,60),' '))$repeat( ,$sub(60,$len($left(%artist% - %title%,$strrchr($left(%artist% - %title%,60),' ')))))%_length%
    $mid(%artist% - %title%,$add($strrchr($left(%artist% - %title%,60),' '),1),60)$repeat( ,$sub(60,$len($mid(%artist% - %title%,$add($strrchr($left(%artist% - %title%,60),' '),1),60)))),$left(%artist% - %title%,60)$repeat( ,$sub(60,$len($left(%artist% - %title%,60))))%_length%)
$loopend()

```

This should work without splitting the words (at the first line).

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [February 9, 2025, 5:30pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/18 "2025-02-09T17:30:28Z")

</div>

Seems to work, individual words are no longer split.  
Thanks for sharing.

I'm just not sure if it's really easier to read:

```auto
05. Acoustic Covers Club - Nobody Like U (From "Turning Red") 02:28
    (Acoustic Instrumental)                                     
06. Acoustic Covers Club - We Don't Talk About Bruno (From 02:31
    "Encanto") (Acoustic Instrumental)                          
07. Acoustic Covers Club - All I Want (From "High School 03:09
    Musical") (Acoustic Instrumental)                           
08. Acoustic Covers Club - Let it Go (From "Frozen") (Acoustic 03:10
    Instrumental)                                               
09. Acoustic Covers Club - When Will My Life Begin? (From 02:55
    "Tangled") (Acoustic Instrumental)                          
10. Acoustic Covers Club - Into the Unknown (From "Frozen II") 02:37
    (Acoustic Instrumental)

```

If there are tracknumbers bigger then 99 there seems to be little problem with the indention on the second line:

 ![image](https://community.mp3tag.de/uploads/default/original/3X/0/3/03dff4796a3b500189fcb96f04bec420dbbe7274.png)  
(The forum software can't show it correctly if 4 leading spaces appears, that's why I can only show a screenshot.)

---

<div class="post-metadata">

### Author: ![tor11](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tor11](https://community.mp3tag.de/u/tor11)
#### Post date: [February 9, 2025, 6:30pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/19 "2025-02-09T18:30:42Z")

</div>

> [@LyricsLover](#):
>
> I'm just not sure if it's really easier to read

Depends on personal preference and the width (for a title) you choose.

> [@LyricsLover](#):
>
> If there are tracknumbers bigger then 99 there seems to be little problem with the indention on the second line:

I haven't tested with that numerous playlist, but I suppose you could use `$num(%track%,3).` or this,

```auto
$loop(%_path%)$regexp($num(%track%,2).,(^\d\d\.),$1 ) $iflonger(%artist% - %title%,60,$left(%artist% - %title%,$strrchr($left(%artist% - %title%,60),' '))$repeat( ,$sub(60,$len($left(%artist% - %title%,$strrchr($left(%artist% - %title%,60),' ')))))%_length%
     $mid(%artist% - %title%,$add($strrchr($left(%artist% - %title%,60),' '),1),60)$repeat( ,$sub(60,$len($mid(%artist% - %title%,$add($strrchr($left(%artist% - %title%,60),' '),1),60)))),$left(%artist% - %title%,60)$repeat( ,$sub(60,$len($left(%artist% - %title%,60))))%_length%)
$loopend()

```

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [February 9, 2025, 6:34pm UTC](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858/20 "2025-02-09T18:34:13Z")

</div>

Yep, that new version works fine:

 ![image](https://community.mp3tag.de/uploads/default/original/3X/9/9/9960b4316d7cb91bf92854fd34b8f03eaca7fc67.png)  
 ![image](https://community.mp3tag.de/uploads/default/original/3X/1/a/1a01db7d83d158332038630feabc3cd945390c1b.png)

[Next page](https://community.mp3tag.de/t/how-to-align-track-length-during-nfo-export/8858.md?page=2)
