# Export to TXT and sorting - some help needed

**URL:** https://community.mp3tag.de/t/export-to-txt-and-sorting-some-help-needed/5484
**Category:** Export
**Created:** [September 23, 2007, 10:19am UTC](https://community.mp3tag.de/t/export-to-txt-and-sorting-some-help-needed/5484 "2007-09-23T10:19:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![supertagger](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@supertagger](https://community.mp3tag.de/u/supertagger)
#### Post date: [September 23, 2007, 10:19am UTC](https://community.mp3tag.de/t/export-to-txt-and-sorting-some-help-needed/5484/1 "2007-09-23T10:19:41Z")

</div>

Hi,

I previously wanted to use DANO's script and sort by date. Since then, and since noone seemed to know how this would work, I moved to a pure text-file export.

~~I want to create this when I am in my folder C:\music, scanning all the albums that I have (all in folders \artist\album) generating a list that looks like this example scan:~~

2007-09-19 - [Rock] Feist - Town Hall, NYC 2007-06-12 [Bootleg] (2007) [MP3 |182kbps| 127.44 MB]  
2007-08-06 - [Soundtrack] OSTHans Zimmer - Rain Man (1988) [MP3 |192kbps| 43.22 MB]  
2007-07-17 - [Tango] Various - Tango Album (Disc 2) (2006) [MP3 |196kbps| 134.81 MB]

I have 3 problems right now:

1. I am replacing the %artist% field with 'Various' here in case the parent directory is named "Various". I would like to add the condition that if that directory's name is "Soundtracks" it should use 'OST' instead of artist. How can I add TWO conditions? (I have NOT used the Album Artist tag in my collection, so a workaround would be better)

Current setting generating above listing including the error that the artist still appears after 'OST' in the second album from top:

$if($eql($left(%\_parent\_directory%,11),Soundtracks),OST,)$if($eql($left(%\_parent\_directory%,7),Various),Various,%artist%) - %album%

1. Some albums have several discs, like the last one in the listing. What happens is that since I am using %album% for the album title, it always depicts the last disc of a set, i.e. (Disc 2). Is there a way to only display the main part of the title, i.e. 'Tango Album', with "Disc 2" not appearing?

**Alright, the above mentioned problems have been resolved by myself. If anyone needs someinfo, let me know. BUT the question remains: How can I limit inversely sorted loops?**  
   
3) Since I reversed the $loop function to sort starting at most recent additions, I went with the suggested method by Dano:

$loop($sub(%\_file\_create\_datetime\_raw%,10000000000))

I added another loop (by artist) to achieve a good sorting mechanism. Problem is: if I only want the last 100 albums to appear in my list, I would usually say

$loop($sub(%\_file\_create\_datetime\_raw%,100))

but this makes the sorting not work anymore. Also, if I add this number after the additional $loop for artists MP3TAG reproducibly crashes. What would be a way to limit the output to 100 lines i.e. albums?

Thank you very much for your help.

supertagger

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [September 27, 2007, 11:30am UTC](https://community.mp3tag.de/t/export-to-txt-and-sorting-some-help-needed/5484/2 "2007-09-27T11:30:44Z")

</div>

I think the additional limit in $loop is only intended for fields which return the same content on several files, e.g. %album% whereas %\_file\_create\_datetime\_raw% is different for each file.

To limit the output you could try to check if the %\_counter% is smaller than 100
