# Conditional Export

**URL:** https://community.mp3tag.de/t/conditional-export/4734
**Category:** Export
**Created:** [April 12, 2007, 9:19am UTC](https://community.mp3tag.de/t/conditional-export/4734 "2007-04-12T09:19:41Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![JFord](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jford/32/4977_2.png) [@JFord](https://community.mp3tag.de/u/JFord)
#### Post date: [April 12, 2007, 9:19am UTC](https://community.mp3tag.de/t/conditional-export/4734/1 "2007-04-12T09:19:41Z")

</div>

I can't determine why there aren't more questions like mine, but I hope it's not because I am a total bonehead.

I want to create a simple flat text export that exports different information based on what's in the tag.

After struggling I managed to create an export consisting of a unique list of Artist-Album combinations.

My latest quest is to export the comment tag only when it contains certain information, if it doesn't contain the specific text then I want to export blanks. I don't know where in the comment field my search target may appear.

If this is a stupid question then a pointer to "Scripting for Dummies" would be helpful.

---

<div class="post-metadata">

### Author: ![milka](https://community.mp3tag.de/user_avatar/community.mp3tag.de/milka/32/55_2.png) [@milka](https://community.mp3tag.de/u/milka)
#### Post date: [April 12, 2007, 7:51pm UTC](https://community.mp3tag.de/t/conditional-export/4734/2 "2007-04-12T19:51:59Z")

</div>

You should write some concrete examples.  
Why don't you attach your export file ("unique list of Artist-Album combinations") that you made?  
Maybe I can help.

~ milka

---

<div class="post-metadata">

### Author: ![JFord](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jford/32/4977_2.png) [@JFord](https://community.mp3tag.de/u/JFord)
#### Post date: [April 13, 2007, 6:23pm UTC](https://community.mp3tag.de/t/conditional-export/4734/3 "2007-04-13T18:23:23Z")

</div>

Milka -

Thanks so much for your offer.

Here is the script that exports a unique list of Artist-Album (if there is %Album% to export). Is there a better way to do this?

$filename(txt)$loop(%artist%)$loop(%album%)$if($Eql(%album%,),,%artist%-%album%$char(13)$char(10))$loopend()$loopend()

I would like to write a different script that exports Artist-Title, but only if the Comment field contains the characters "R5". I can't determine any way to do that.

---

<div class="post-metadata">

### Author: ![nickless](https://community.mp3tag.de/user_avatar/community.mp3tag.de/nickless/32/36_2.png) [@nickless](https://community.mp3tag.de/u/nickless)
#### Post date: [April 14, 2007, 9:46pm UTC](https://community.mp3tag.de/t/conditional-export/4734/4 "2007-04-14T21:46:00Z")

</div>

> [@JFord](#):
>
> Here is the script that exports a unique list of Artist-Album

AFAIK a unique list do not have equal lines, so it sould be something like this: $filename(test.txt)$loop(%album%-%artist%,1)$if($neql(%album%,),%artist%-%album%

```
,)$loopend()

```

And the artist-title export:

```
$loop(%artist%-%title%)$if($eql($strstr(%comment%,R5),0),,%artist%-%title%
)$loopend()

```

Regards  
nickless

---

<div class="post-metadata">

### Author: ![milka](https://community.mp3tag.de/user_avatar/community.mp3tag.de/milka/32/55_2.png) [@milka](https://community.mp3tag.de/u/milka)
#### Post date: [April 15, 2007, 9:49am UTC](https://community.mp3tag.de/t/conditional-export/4734/5 "2007-04-15T09:49:07Z")

</div>

I had some work to do, but nickless have done it. I test it and it's working nice.

~ milka

---

<div class="post-metadata">

### Author: ![JFord](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jford/32/4977_2.png) [@JFord](https://community.mp3tag.de/u/JFord)
#### Post date: [April 15, 2007, 12:00pm UTC](https://community.mp3tag.de/t/conditional-export/4734/6 "2007-04-15T12:00:08Z")

</div>

This is brilliant! You two are wonderful!

The examples have taught me several basic tricks and approaches I was missing. Character-based languages (APL, RegEx, etc.) require true subtlety to master.

---

<div class="post-metadata">

### Author: ![JFord](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jford/32/4977_2.png) [@JFord](https://community.mp3tag.de/u/JFord)
#### Post date: [April 21, 2007, 5:06pm UTC](https://community.mp3tag.de/t/conditional-export/4734/7 "2007-04-21T17:06:52Z")

</div>

I have finally gotten back to this task. In my testing the artist-title export does not work. The $strstr(%comment%,R5) function returns true when it finds just the letter R, it does not require finding the string "R5".

Can anyone confirm or deny this for me?

---

<div class="post-metadata">

### Author: ![milka](https://community.mp3tag.de/user_avatar/community.mp3tag.de/milka/32/55_2.png) [@milka](https://community.mp3tag.de/u/milka)
#### Post date: [April 24, 2007, 4:55am UTC](https://community.mp3tag.de/t/conditional-export/4734/8 "2007-04-24T04:55:30Z")

</div>

Maybe is some kind of a bug. Can I see your comment tag content?

---

<div class="post-metadata">

### Author: ![JFord](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jford/32/4977_2.png) [@JFord](https://community.mp3tag.de/u/JFord)
#### Post date: [April 24, 2007, 6:50pm UTC](https://community.mp3tag.de/t/conditional-export/4734/9 "2007-04-24T18:50:43Z")

</div>

OK, I guess I am a complete bonehead. I went back to retest the code to provide my results and everything works as I was hoping.

I apologize for the fire drill.

---

<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 27, 2007, 6:31am UTC](https://community.mp3tag.de/t/conditional-export/4734/10 "2007-09-27T06:31:02Z")

</div>

I would like to revive this thread with the following question:

The mentioned conditional export is static - could someone help me generate a conditional export that is based on the date?

My files have a special tag that designates the day I tagged them in the format YYYY-MM-DD. Now, if I run my export in September 2007 (using %\_date% mp3tag generates M/DD/YYYY) I would like to only show those files that I tagged in September 2007, i.e. in which the special tag says 2007-09-XX. I would like this to work not only in that particular month but in any month.

In programming-lingo I would want:

Export files in which specialtag's first 7 digits (e.g.2007-09) equal current month.

Is there a way to do this? I am kind of a greenhorn with scripting and unfortunately stuck... .

Any help is greatly appreciated.

Thanks! 🙂

---

<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, 10:33am UTC](https://community.mp3tag.de/t/conditional-export/4734/11 "2007-09-27T10:33:16Z")

</div>

```
$if($eql($replace($left(%your field%,7),-0,-),$regexp(%_date%,^(\d\d?)/\d\d?/(\d\d\d\d)$,$2-$1)),Yes,No)

```

In the Yes part goes the stuff you want to output if the condintion is fulfilled and No part stays empty.

---

<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 27, 2007, 10:44am UTC](https://community.mp3tag.de/t/conditional-export/4734/12 "2007-09-27T10:44:31Z")

</div>

Oh wow, thank you Dano, I will try this out right away!

Do you by any chance also know how I can limit the number of loops when I sort inversely using the $sub(%fieldofinterest%,10000000) method? MP3TAG always crashes when I put it this way:

$loop($sub(%fieldofinterest%),10000000000),50) \<--instead of limiting it to 50 loops it just keeps on going OR crashes ... .

Thank you.

st
