# Export csv file in same order as shown in mp3tag

**URL:** https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814
**Category:** Support
**Created:** [June 11, 2025, 12:16pm UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814 "2025-06-11T12:16:30Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Zentie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zentie/32/18249_2.png) [@Zentie](https://community.mp3tag.de/u/Zentie)
#### Post date: [June 11, 2025, 12:16pm UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/1 "2025-06-11T12:16:30Z")

</div>

Hi guys, when exporting to csv, the order of the items change with relation to what is shown in the main mp3tag window. Is there any easy way to keepp the order the same?

---

<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: [June 11, 2025, 12:19pm UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/2 "2025-06-11T12:19:54Z")

</div>

Unfortunately, you do not show us the export script.  
In general, the most important $loop() should be $loop(1) and should not contain any variable or so.

---

<div class="post-metadata">

### Author: ![Zentie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zentie/32/18249_2.png) [@Zentie](https://community.mp3tag.de/u/Zentie)
#### Post date: [June 12, 2025, 5:41am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/3 "2025-06-12T05:41:27Z")

</div>

Here is the script, attached. Please note the "played1" and "played2" are custom fields for personal use. They may be temporarily omitted.  
[csv-playlist.mte](https://community.mp3tag.de/uploads/short-url/qNdrnvFDWUZCqxxQX60HreKUE6X.mte) (201 Bytes)

---

<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: [June 12, 2025, 5:42am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/4 "2025-06-12T05:42:22Z")

</div>

Instead of  
`$loop(%_filename_ext%)`  
use  
`$loop(1)`

---

<div class="post-metadata">

### Author: ![Zentie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zentie/32/18249_2.png) [@Zentie](https://community.mp3tag.de/u/Zentie)
#### Post date: [June 12, 2025, 5:43am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/5 "2025-06-12T05:43:05Z")

</div>

Thanks, I can certainly try that.

---

<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: [June 12, 2025, 5:44am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/6 "2025-06-12T05:44:18Z")

</div>

On a foot note:  
This is the script I got:

```auto
$filename(csv,utf-16)Sequence;Title;Artist;Album;Length;Duration;Start;End
$loop(%_filename_ext%)%sequence%;%title%;%artist%;%album%;%_length_seconds%;;;;
$loopend()Divide;length;by;86400;for;mm:ss

```

IMHO it does not contain

> [@Zentie](#):
>
> "played1" and "played2"

So is this the correct script?

---

<div class="post-metadata">

### Author: ![Zentie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zentie/32/18249_2.png) [@Zentie](https://community.mp3tag.de/u/Zentie)
#### Post date: [June 12, 2025, 5:55am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/7 "2025-06-12T05:55:52Z")

</div>

That is the correct script; sorry, still early morning and I haven't woken up yet!  
I've tried your suggestion and it is almost the way I want it. Please see attached. I need the csv to be in exactly the same order as the m3u file. I can do that by adding the field 'sequence', then physically change numbers from top to bottom, 1 to how ever many, use the data sorting in the csv file. However, there should be another way.

 ![after exporting](https://community.mp3tag.de/uploads/default/original/3X/e/9/e9dd5b018431859adb3b403daa60450b0e37ec42.png)  
 ![from m3u file](https://community.mp3tag.de/uploads/default/original/3X/9/4/940bca1237cf21ebec9c8925b6579cd4fc2a69ef.png)

---

<div class="post-metadata">

### Author: ![Zentie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zentie/32/18249_2.png) [@Zentie](https://community.mp3tag.de/u/Zentie)
#### Post date: [June 12, 2025, 5:57am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/8 "2025-06-12T05:57:11Z")

</div>

[csv-playlist2.mte](https://community.mp3tag.de/uploads/short-url/4Weqw21PUgWPp9EFd0DIHEQLZqd.mte) (187 Bytes)  
This is the modified file.

---

<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: [June 12, 2025, 6:01am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/9 "2025-06-12T06:01:46Z")

</div>

```auto
$filename(csv,utf-16)Sequence;Title;Artist;Album;Length;Duration;Start;End
$loop(1)%sequence%;%title%;%artist%;%album%;%_length_seconds%;;;;
$loopend()Divide;length;by;86400;for;mm:ss

```

The modification looks OK to me? Doesn't it produce the expected result?

> [@Zentie](#):
>
> I can do that by adding the field 'sequence', then physically change numbers from top to bottom

The field Sequence should not be necessary with $loop(1).

---

<div class="post-metadata">

### Author: ![Zentie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zentie/32/18249_2.png) [@Zentie](https://community.mp3tag.de/u/Zentie)
#### Post date: [June 12, 2025, 7:38am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/10 "2025-06-12T07:38:15Z")

</div>

Wow! Thanks very much, the exact way I need it to be. Have a great day/evening. 😃

---

<div class="post-metadata">

### Author: ![Zentie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zentie/32/18249_2.png) [@Zentie](https://community.mp3tag.de/u/Zentie)
#### Post date: [June 12, 2025, 8:24am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/11 "2025-06-12T08:24:20Z")

</div>

Is there any way I can add a field, such as "item", which automatically starts at 1 and counting the number of items in a list?

---

<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: [June 12, 2025, 8:29am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/12 "2025-06-12T08:29:50Z")

</div>

> [@Zentie](#):
>
> Is there any way I can add a field, such as "item",

Where? In the export script? Then try:

```auto
$filename(csv,utf-16)Sequence;Title;Artist;Album;Length;Duration;Start;End
$loop(1)$num(%_counter%,2);%title%;%artist%;%album%;%_length_seconds%;;;;
$loopend()Divide;length;by;86400;for;mm:ss

```

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [July 12, 2025, 8:30am UTC](https://community.mp3tag.de/t/export-csv-file-in-same-order-as-shown-in-mp3tag/68814/13 "2025-07-12T08:30:26Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
