# Check If All Specified Tags Exist Before Doing Action

**URL:** https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753
**Category:** General Discussion
**Created:** [March 26, 2015, 4:32pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753 "2015-03-26T16:32:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![weezywee](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/fbc32d/32.png) [@weezywee](https://community.mp3tag.de/u/weezywee)
#### Post date: [March 26, 2015, 4:32pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/1 "2015-03-26T16:32:05Z")

</div>

How do I make Mp3tag check if tags exists before executing action. I know how to make it check for a single tag but I need it to check for multiple tags and only execute if it contains all of them.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [March 26, 2015, 4:55pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/2 "2015-03-26T16:55:01Z")

</div>

A few days ago there was a similar theme ...  
[Quicker Filter Options](https://community.mp3tag.de/t/16721/2)

Please explain what you want to achieve in special, ...  
because it is not needed always to check all circumstances before doing something in Mp3tag, ...  
but there might come up some procedure, where pre-checking is advisable.

DD.20150326.1854.CET

---

<div class="post-metadata">

### Author: ![weezywee](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/fbc32d/32.png) [@weezywee](https://community.mp3tag.de/u/weezywee)
#### Post date: [March 26, 2015, 4:59pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/3 "2015-03-26T16:59:32Z")

</div>

When I run actions to rename files, I don't want the file names changed unless all the tags I specify exist.

Edit: That thread is talking about filters. I need to be able to use it in a formatting string.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [March 26, 2015, 5:05pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/4 "2015-03-26T17:05:49Z")

</div>

> [@weezywee](#):
>
> When I run actions to rename files, I don't want the file names changed unless all the tags I specify exist.  
> Edit: That thread is talking about filters. I need to be able to use it in a formatting string.

You can use the Mp3tag filter section for testing and training, ...  
then mimic the filter expression into formatstring to be used within action.

Check if one tag-field exists ...  
$if(%TAGFIELD%,then,else)

Check if two tag-fields exists ...  
$if($and(%TAGFIELD\_THIS%,%TAGFIELD\_THAT%),then,else)

Check if three tag-fields exists ...  
$if($and(%TAGFIELD\_THIS%,%TAGFIELD\_THAT%,%TAGFIELD\_OTHER%),then,else)

Check if TITLE tag exists together with TRACK or TOTALTRACKS ...  
$if($and(%TITLE%,$or(%TRACK%,%TOTALTRACKS%)),then,else)

DD.20150326.1919.CET

---

<div class="post-metadata">

### Author: ![weezywee](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/fbc32d/32.png) [@weezywee](https://community.mp3tag.de/u/weezywee)
#### Post date: [March 26, 2015, 5:17pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/5 "2015-03-26T17:17:08Z")

</div>

> [@DetlevD](#):
>
> You can use the Mp3tag filter section for testing and training, ...  
> then mimic the filter expression into formatstring to be used within action.
> 
> DD.20150326.1905.CET

That's what I don't know how to do.

Format Value  
Field  
\_FILENAME  
Format String  
$if(%albumartist%,%albumartist% - %track% - %title%,%\_filename%)

This string checks if the %albumartist% tag is there and if it is it renames the file to %albumartits% - %track% - %title%.flac and if the %albumartist% tag is there it leaves the name the same. Thats all good but if the %track% or %title% is missing, the the file name will be messed up.  
$if(%albumartist%,%albumartist% - %track% - %title%,%\_filename%)

How do I make this check check or %albumartist% and %title% before doing the action?

---

<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 26, 2015, 5:20pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/6 "2015-03-26T17:20:56Z")

</div>

> [@weezywee](#):
>
> When I run actions to rename files, I don't want the file names changed unless all the tags I specify exist.
> 
> Edit: That thread is talking about filters. I need to be able to use it in a formatting string.

Why start actions on files that apparently do not fulfill the requirements?  
Renaming would be a little faster if only those files are treated that should be treated.  
If you want to avoid that empty fields (that don't exist) find their way into filenames, use the square brackets around these variables. This creates the part only, if there is a value in that variable, e.g.  
%artist%[\_ %composer%] \_ %title%  
adds the composer part only if composer is filled.

---

<div class="post-metadata">

### Author: ![weezywee](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/fbc32d/32.png) [@weezywee](https://community.mp3tag.de/u/weezywee)
#### Post date: [March 26, 2015, 11:12pm UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/7 "2015-03-26T23:12:41Z")

</div>

> [@ohrenkino](#):
>
> Why start actions on files that apparently do not fulfill the requirements?  
> Renaming would be a little faster if only those files are treated that should be treated.  
> If you want to avoid that empty fields (that don't exist) find their way into filenames, use the square brackets around these variables. This creates the part only, if there is a value in that variable, e.g.  
> %artist%[\_ %composer%] \_ %title%  
> adds the composer part only if composer is filled.

It's not that I'm intending to run the actions on the files that don't have the tags. It's a way to prevent it from happening accidentally. Based on the suggestions I've got so far, I assume it's not possible to do what I want. I appreciate the help but my initial inquiry was not answered. I have very specific wants/needs and I would just like to know how to do exactly what I asked about. If isn't possible or if you don't know how too just say that. I'll find another way do it or just not worry about it.

Again, thanks for the suggestions. I will add the brackets in to my strings so that blank fields don't get written if I can't figure out a way to do what I want.

---

<div class="post-metadata">

### Author: ![weezywee](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/fbc32d/32.png) [@weezywee](https://community.mp3tag.de/u/weezywee)
#### Post date: [March 27, 2015, 3:14am UTC](https://community.mp3tag.de/t/check-if-all-specified-tags-exist-before-doing-action/16753/8 "2015-03-27T03:14:07Z")

</div>

> [@DetlevD](#):
>
> You can use the Mp3tag filter section for testing and training, ...  
> then mimic the filter expression into formatstring to be used within action.
> 
> Check if one tag-field exists ...  
> $if(%TAGFIELD%,then,else)
> 
> Check if two tag-fields exists ...  
> $if($and(%TAGFIELD\_THIS%,%TAGFIELD\_THAT%),then,else)
> 
> Check if three tag-fields exists ...  
> $if($and(%TAGFIELD\_THIS%,%TAGFIELD\_THAT%,%TAGFIELD\_OTHER%),then,else)
> 
> Check if TITLE tag exists together with TRACK or TOTALTRACKS ...  
> $if($and(%TITLE%,$or(%TRACK%,%TOTALTRACKS%)),then,else)
> 
> DD.20150326.1919.CET

Thanks, it works.
