# Need to export a csv file of a list of songs!

**URL:** <https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853>\
**Category:** Support\
**Created:** [March 15, 2019, 6:58am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853 "2019-03-15T06:58:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 6:58am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/1 "2019-03-15T06:58:04Z")

</div>

I've done this dozens of times on another PC but I can't figure out how to write a new export script to do this on a new laptop that I have here. I'm not in my home office, but I have to get this done right away. I'm panicked, as I need to upload the CSV file now.

I know there's a sample script in the export list of ready-made scripts, but I can't get it to work. I have a list of 46 songs with track number, duration, artist, title, album name, year released and label. It's a total of 47 records including the header row. I need to get it into an Excel file so that I can upload it to a web-based site.

[dennisb@kvmr.org](mailto:dennisb@kvmr.org)

---

<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:** [March 15, 2019, 7:12am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/2 "2019-03-15T07:12:37Z")

</div>

> [@d2b](#):
>
> I know there's a sample script in the export list of ready-made scripts, but I can't get it to work

What do you mean? You don't know how to export? -\> Select the files, select the export script, execute the script, done.

Or you get strange results in some fields as the included data contains commas and/or semikolons?  
Anyway: show us the script that you use and tell us which fields you want to export.  
Here is a very plain export script that uses the tab character as field separator - usually works better than commas:  
`$filename(csv,utf-16)Interpret$char(9)Composer$char(9)Album$char(9)Pfad $loop(%artist%)%artist%$char(9)%composer%$char(9)%album%$char(9)%title%$char(9)%_path%`  
`$loopend()`

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 7:29am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/3 "2019-03-15T07:29:09Z")

</div>

> [@ohrenkino](#):
>
> Pfad $loop(%artist%)%artist%$char(9)

I don't understand the portion of text in the middle row above. What is Pfad and why does %artist% appear twice?

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 7:32am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/4 "2019-03-15T07:32:44Z")

</div>

Here is the script I've been trying. I modeled it after the CSV example script.

$filename(csv,utf-8)TN;LENGTH;ARTIST;TITLE;ALBUM;YEAR;LABEL;  
$loop(%\_path%)$num(%tracknumber%,2);%length%;%artist%;%title;%album%;%year%;%label%;$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:** [March 15, 2019, 7:33am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/5 "2019-03-15T07:33:12Z")

</div>

The `$loop()` statement defines by which field the whole export should be sorted (in this case by the field %artist%)  
That what is outside the $loop() is the instruction to output the contents of the referenced field. So you have to use %artist% to sort by artist and use %artist% to see what is in the field artist.  
The $char(9) is the character code for the tab character which works well as field separator

---

<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:** [March 15, 2019, 7:34am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/6 "2019-03-15T07:34:00Z")

</div>

> [@d2b](#):
>
> $loop(%\_path%)$num(%tracknumber%,2);

I think that should be %track% instead of %tracknumber%

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 7:37am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/7 "2019-03-15T07:37:04Z")

</div>

These are flac files, The field name for the track number is tracknumber.

---

<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:** [March 15, 2019, 7:41am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/8 "2019-03-15T07:41:12Z")

</div>

so, what is it that does not work?

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 7:59am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/9 "2019-03-15T07:59:55Z")

</div>

and what is "Pfad" in the script?

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 8:04am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/10 "2019-03-15T08:04:41Z")

</div>

The script runs but the Excel file that opens has strange numeric characters at the beginning of each line, and the field values are not separated into column. Some fields are missing as well.

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 8:07am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/11 "2019-03-15T08:07:18Z")

</div>

Also, the rows in the spreadsheet are in random order rather than in the order listed in the mp3tag rows.

---

<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:** [March 15, 2019, 8:12am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/12 "2019-03-15T08:12:28Z")

</div>

If you sort by path and the path is the same for all, the you get a random order.  
Use  
$loop(1) instead of $loop(%\_path%)  
This copies the order that is shown in the files 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:** [March 15, 2019, 8:14am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/13 "2019-03-15T08:14:48Z")

</div>

> [@d2b](#):
>
> the field values are not separated into column

This depends on what you local excel interprets as "comma": whether it is really a comma or the semicolon.  
Currently, you use the semicolon, perhaps the comma is better (but this will be problematic if the data in the fields contains commas as well. THen you would have to enclose the field names in ").

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 8:15am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/14 "2019-03-15T08:15:08Z")

</div>

I have a working script on the computer in my home office, but that's 50km from here, it's night time and I cannot drive at night. I just can't duplicate it here.

I use another script successfully here to export a text tile. I was smart enough to store that one in my dropbox. Here it is:

$filename(txt,utf-8)TRACK NUMBER / DURATION / ARTIST / TITLE / ALBUM / YEAR / LABEL

$loop(%\_path%)$num(%tracknumber%,2) / %length% / %artist% / %title% / %album% / %year% / %label%

$loopend()

It yields a very nice double-spaced, easily read list of the songs that I also need to upload/import as a csv file (minus the spaces and "/" characters. As I recall, my working CSV script on the other PC looks very similar to this one.

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 8:17am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/15 "2019-03-15T08:17:03Z")

</div>

ecxept of course the fields are not double-spaced.

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 8:28am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/16 "2019-03-15T08:28:27Z")

</div>

What is wrong with this csv export script?

$filename(csv,utf-8)TN,LENGTH,ARTIST,TITLE,ALBUM,YEAR,LABEL  
$loop(%\_path%)$num(%tracknumber%,2),%length%,%artist%,%title%,%album%,%year%,%label%  
$loopend()

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 8:29am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/17 "2019-03-15T08:29:48Z")

</div>

I know about the need for "s if there are commas in the values.

---

<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:** [March 15, 2019, 8:45am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/18 "2019-03-15T08:45:31Z")

</div>

I get proper results when I use a valid separator and the field %\_length%.  
If you don't, then you would have to show us the original data, the actual output and the intended output.

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 9:05am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/19 "2019-03-15T09:05:02Z")

</div>

That script worked for me. Thank you for all of the time and effort you put in to helping me! I really appreciate it.

Dennis, aka "d2b"

---

<div class="post-metadata">

**Author:** ![d2b](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@d2b](https://community.mp3tag.de/u/d2b)\
**Post date:** [March 15, 2019, 9:08am UTC](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853/20 "2019-03-15T09:08:19Z")

</div>

We create a FLAC tag with the name LENGTH from %\_length%.

[Next page](https://community.mp3tag.de/t/need-to-export-a-csv-file-of-a-list-of-songs/44853.md?page=2)
