# Export Loop question

**URL:** <https://community.mp3tag.de/t/export-loop-question/57292>\
**Category:** Support\
**Created:** [May 13, 2022, 7:46am UTC](https://community.mp3tag.de/t/export-loop-question/57292 "2022-05-13T07:46:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 13, 2022, 7:46am UTC](https://community.mp3tag.de/t/export-loop-question/57292/1 "2022-05-13T07:46:07Z")

</div>

I am just starting to learn this export function and it works REALLY great (been using Mp3tag for years now so never old to learn hahahahaha)

I have this export script (MTE)

```auto
$filename(txt,utf-8)

Quality/Bitrate: %_bitrate%
Size: %_total_size%
Length: %_total_time%
Files: %_total_files%

$loop(%_path%)[CD $num(%discnumber%,01)] 'Track' %track%. %artist% - %title%	'['%_length%']'
$loopend()

```

How can I make it that for every CD only one time the "CD & Disc number" is printed, for example like this

CD 1

Track 1 test - test [1:30]  
Track 2  
etc etc

CD 2

Track 1 test1 - test1 [1:10]  
etc  
etc  
etc

TiA

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 13, 2022, 7:55am UTC](https://community.mp3tag.de/t/export-loop-question/57292/2 "2022-05-13T07:55:28Z")

</div>

```auto
$loop(%_path%)[CD $num(%discnumber%,01)] 'Track' %track%. %artist% - %title%	'['%_length%']'
$loopend()

```

-\>

```auto
$loop(%_path%)$loop(%discnumber%,1)[CD $num(%discnumber%,01)] $loop($num(%track%,3))'Track' %track%. %artist% - %title%	'['%_length%']'
$loopend()$loopend()$loopend()
```

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 13, 2022, 8:00am UTC](https://community.mp3tag.de/t/export-loop-question/57292/3 "2022-05-13T08:00:21Z")

</div>

Wow a bit more complicated then I thought but it makes sense.

Another question if I may, does this go Disc 1-\>2-\>3-\>4 or random!

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 13, 2022, 8:15am UTC](https://community.mp3tag.de/t/export-loop-question/57292/4 "2022-05-13T08:15:30Z")

</div>

First you sort by the path ... and if in that path there are files with a discnumber, then this is sorted, ascending, but each number is taken only once. Then the entries for TRACK are sorted, also ascending.

I would say that this is not random (which you could easily try out).  
What puzzles me is the first sort criterion \_PATH - wouldn't `$loop(%albumartist%%album%)` make much more sense?

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 13, 2022, 8:27am UTC](https://community.mp3tag.de/t/export-loop-question/57292/5 "2022-05-13T08:27:22Z")

</div>

> [@ohrenkino](#):
>
> What puzzles me is the first sort criterion \_PATH - wouldn't `$loop(%albumartist%%album%)` make much more sense?

Please do notice this is my first steps on the export path 😉

It's a compilation of all different artist

CD 1 has artist a, artist b and artist c  
CD 2 has artist c and artist d  
CD 3 has artist e  
etc etc

If I did `%albumartist%%album%` wouldn't that ... things up?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 13, 2022, 8:37am UTC](https://community.mp3tag.de/t/export-loop-question/57292/6 "2022-05-13T08:37:38Z")

</div>

> [@mjcm](#):
>
> If I did `%albumartist%%album%` wouldn't that ... things up?

Not, if ALBUMARTIST is filled with decent data, e.g. "Various Artists" for a compilation.  
Alternatively, you could sort by %album%$num(%discnumber%,1) - but there I see the problem that "Greatest Hits" may be sorted all into 1 group.  
But I don't know what your data looks like, perhaps \_PATH is the best initial criterion.

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 13, 2022, 8:43am UTC](https://community.mp3tag.de/t/export-loop-question/57292/7 "2022-05-13T08:43:37Z")

</div>

Thx

I am not using Various Artists

I am only using very BASIC for this one

artist  
title  
Album Title (same across the whole compilation)  
track number (2 digits so no Track/Total Tracks)  
Genre  
CD Number (2 digits only so no DISC/Total Discs)

and that is it.

edit: So I want sorted by CD nr (low to high) and per CD per track number (also low to high (with 1 being low 🤣

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 13, 2022, 9:19am UTC](https://community.mp3tag.de/t/export-loop-question/57292/8 "2022-05-13T09:19:44Z")

</div>

Have you tried my initial proposition?

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 13, 2022, 9:21am UTC](https://community.mp3tag.de/t/export-loop-question/57292/9 "2022-05-13T09:21:27Z")

</div>

Not yet sorry!

We have a massive Thunder storm here, and everything except my laptop is shutdown!

Will of course report back (count on it 😉)

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [May 13, 2022, 1:39pm UTC](https://community.mp3tag.de/t/export-loop-question/57292/10 "2022-05-13T13:39:42Z")

</div>

AlbumArtist is an essential field for most current players. This is the field that will allow their libraries to distinguish common album title like Greatest Hits, but even some others like “Faith” by both Faith Hill and George Michael as an example. For most albums you can simply copy the value you already have from the Artist field. Be sure to remove any contributing artists, etc.

Deciding on an appropriate AlbumArtist name for your library to assign to compilation albums is also key to ensuring good library management. The most common one is “Various Artists” but you can decide what works best for you.

Once you have this field, creating directory folder structures becomes a very simple task.

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 14, 2022, 3:26am UTC](https://community.mp3tag.de/t/export-loop-question/57292/11 "2022-05-14T03:26:07Z")

</div>

I am not creating a Directory Structure. I am just creating a text file with the listing of the CD's under divided by CD Nr and within the CD the Tracks sorted by Number 1

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [May 14, 2022, 3:51am UTC](https://community.mp3tag.de/t/export-loop-question/57292/12 "2022-05-14T03:51:17Z")

</div>

It is the same concept whether you are updating the file directory, or exporting the data - if you want to keep the albums grouped together the common factor is a consistent AlbumArtist field. If you make this update it will be much easier to do anything else later on.

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 14, 2022, 4:12am UTC](https://community.mp3tag.de/t/export-loop-question/57292/13 "2022-05-14T04:12:02Z")

</div>

> [@ohrenkino](#):
>
> ```auto
> $loop(%_path%)$loop(%discnumber%,1)[CD $num(%discnumber%,01)] $loop($num(%track%,3))'Track' %track%. %artist% - %title%	'['%_length%']'
> $loopend()$loopend()$loopend()
> 
> ```

Sorry but that did not do it

This is whole script

```auto
$filename(txt,utf-8)

$loop(%_path%)$loop(%discnumber%,1)[CD $num(%discnumber%,01)] $loop($num(%track%,3))'Track' %track%. %artist% - %title%	'['%_length%']'
$loopend()$loopend()$loopend()

```

Output was this

> CD 1 Track 01. Artist 1 - "track1" [01:01]  
> CD 1 Track 02. Artist 1 - "track2" [01:01]  
> etc etc etc

Edit: I changed path for `%albumartist%%album%` and that messes it completely BUT we are almost there 😉

> CD 23 Track 1. blahahahahahaha  
> Track 2. blahahaha  
> Track 3. blah  
> CD 6 Track 1. blahblahblah  
> Track 2. blahahaha  
> Track 3. blah

See the sorting

Ps: AlbumArtist I have set NOT to various but to the actual performer

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 14, 2022, 4:21am UTC](https://community.mp3tag.de/t/export-loop-question/57292/14 "2022-05-14T04:21:30Z")

</div>

This one seems to do the trick

```auto
$loop(%discnumber%)$loop(%discnumber%,1)[CD $num(%discnumber%,01)] $loop($num(%track%,3))'Track' %track%. %artist% - %title%	'['%_length%']'
$loopend()$loopend()$loopend()

```

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 14, 2022, 5:56am UTC](https://community.mp3tag.de/t/export-loop-question/57292/15 "2022-05-14T05:56:24Z")

</div>

> [@mjcm](#):
>
> This one seems to do the trick

I do not see the logic in looping the discnumber twice ... but if you are satisfied - ok.  
I mentioned the sorting criterion

> [@mjcm](#):
>
> `%albumartist%%album%`

before I knew that you have not filled ALBUMARTIST. See the discussion wit @MotleyG why the lack of data in that field is not the optimum way.

You asked about the loops - and I think you see now how they work.

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 14, 2022, 8:15am UTC](https://community.mp3tag.de/t/export-loop-question/57292/16 "2022-05-14T08:15:25Z")

</div>

> [@ohrenkino](#):
>
> I do not see the logic in looping the discnumber twice ... but if you are satisfied - ok.  
> I mentioned the sorting criterion

I was just experimenting because you comment about \_path, so I have no idea either why it loops twice, but it works

With some (cosmetic tweaking) I now get this

> CD 1
> 
> Track 1 artist1 - test1 [1:30]  
> Track 2 artist2 - test2 [1:10]  
> etc etc
> 
> CD 2
> 
> Track 1 artist2 - testx [3:10]  
> Track 1 artist3 - testxy [1:11]  
> etc  
> etc  
> etc

Thx for the help

Ps: This is not for my own use, my Files have a lot more fields in them.

Edit: I think know why the loop 2x

The Dir structure on the drive is

01  
\Track 1  
etc  
02  
\Track 1  
etc  
03  
\Track 1  
etc  
etc etc etc

Does that makes sense?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 14, 2022, 8:21am UTC](https://community.mp3tag.de/t/export-loop-question/57292/17 "2022-05-14T08:21:07Z")

</div>

> [@mjcm](#):
>
> so I have no idea either why it loops twice, but it works

If you dare, you could leave out the $loop(%discnumber%,1)

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 14, 2022, 10:27am UTC](https://community.mp3tag.de/t/export-loop-question/57292/18 "2022-05-14T10:27:39Z")

</div>

> [@ohrenkino](#):
>
> If you dare, you could leave out the $loop(%discnumber%,1)

Of course I dare because I already have the desired result 😉

I guess that would mean removing out 1 loopend?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 14, 2022, 10:41am UTC](https://community.mp3tag.de/t/export-loop-question/57292/19 "2022-05-14T10:41:54Z")

</div>

> [@mjcm](#):
>
> removing out 1 loopend

Exactly. The $loop(%discnumber%,1) would limit the occurrance of the sort criterion to the first incidence. But as you alread sorted by path which most likely also includes the discnumber, further limitatons would not be necessary.

---

<div class="post-metadata">

**Author:** ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)\
**Post date:** [May 15, 2022, 6:57am UTC](https://community.mp3tag.de/t/export-loop-question/57292/20 "2022-05-15T06:57:17Z")

</div>

> [@ohrenkino](#):
>
> Exactly. The $loop(%discnumber%,1) would limit the occurrance of the sort criterion to the first incidence. But as you alread sorted by path which most likely also includes the discnumber, further limitatons would not be necessary.

Yep Suc6

Removed $loop(%discnumber%) and 1 $loopend() and got the same results!!

Thx for the help, really appreciated!

[Next page](https://community.mp3tag.de/t/export-loop-question/57292.md?page=2)
