# Create action field based on length and files

**URL:** <https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115>\
**Category:** Support\
**Created:** [May 29, 2023, 6:47pm UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115 "2023-05-29T18:47:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![may](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@may](https://community.mp3tag.de/u/may)\
**Post date:** [May 29, 2023, 6:47pm UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/1 "2023-05-29T18:47:59Z")

</div>

Is it possible to create an action that creates a RELEASETYPE field based on the amount of files and total duration?

> Singles are less than 30 minutes with 3 or fewer tracks. EPs are up to 30 minutes in length with no more than 6 songs. And albums contain 6 or more songs with a total length of over 30 minutes.

RELEASETYPE value:

- single
- ep
- album

Thanks in advance

---

<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:** [May 29, 2023, 6:50pm UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/2 "2023-05-29T18:50:15Z")

</div>

I doubt that.  
As MP3tag does not compare the data between two or more files I do not think that an album can be detected and the length will also not be added.

If you want to get such data, you would have to create an export script, prepare the output in a way that the files belonging to an album can be grouped together and the data be written back to the files.

---

<div class="post-metadata">

**Author:** ![may](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@may](https://community.mp3tag.de/u/may)\
**Post date:** [May 30, 2023, 8:55am UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/3 "2023-05-30T08:55:02Z")

</div>

Ok, I hoped Mp3Tag had a function to get the album length and total tracks and write it to add tag and use this in a Action.

I will do some research if I can write a Python script for Beets which can do this.

---

<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:** [May 30, 2023, 9:18am UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/4 "2023-05-30T09:18:01Z")

</div>

Something very similar has been discussed in this thread:

> [@How to create a folder structure based on number of track](https://community.mp3tag.de/t/how-to-create-a-folder-structure-based-on-number-of-track/44451):
>
> I'm now using an action to create folders in the format %year% - %album% With the following expression using Format Value: [$left(%year%,4) -]%album%\%\_FILENAME% But I also would like to create a folder for Singles, EP's and Albuns automatically, using the following logic: 1-3 songs: Single 4-6: EP 7\> Album That way I'd have a folder structure like this: Single/ 2019 - Album\_name 2018 - Album\_name EP/ 2017 - Album\_name 2016 - Album\_name How can I do that? Maybe comparing the to…

including some pieces that would create strange results when treated automatically.

As a first approach: if you have the files in separate folders, then you could run the track numbering wizard to include the totals and then check the total number of files as stored in the field TRACK.  
You could filter or check these numbers and then apply the action to fill the relieasetype (which is a user-defined field anyway and will not be picked up by most players - MEDIATYPE would come closest, I think)  
The length, though, will not be included

---

<div class="post-metadata">

**Author:** ![may](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@may](https://community.mp3tag.de/u/may)\
**Post date:** [May 30, 2023, 9:29am UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/5 "2023-05-30T09:29:26Z")

</div>

Thanks for the update.

My files are in separate folders per album.  
I just read the other topic, this is exactly why I was thinking to have 2 conditions total tracks and album duration.  
Plex is using RELEASETYPE field to separate singles from albums.

---

<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:** [May 30, 2023, 9:33am UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/6 "2023-05-30T09:33:50Z")

</div>

Wouldn't the track length be also an indicator for album sized tracks?  
You would not have to calculate the whole album but check that the file is no longer than x minutes - this would all in all indicate an EP or so.

---

<div class="post-metadata">

**Author:** ![may](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@may](https://community.mp3tag.de/u/may)\
**Post date:** [May 30, 2023, 1:42pm UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/7 "2023-05-30T13:42:26Z")

</div>

I am not sure, what I wrote in my initial message was a quick Google 😃

[Here](https://labelworx.zendesk.com/hc/en-us/articles/115005981369-What-is-the-difference-between-a-Single-EP-and-Album-) I read:

> A **Single** is a release containing one to three songs that are under 10 minutes each.
> 
> An **EP** contains four to six songs with a total running time of 30 minutes or less.
> 
> An **Album** is a release that contains over 30 minutes of music, a continuous DJ mix, or six different tracks from the same artist.

And [here](https://sugomusic.com/what-is-the-difference-between-a-single-ep-and-album/#:~:text=Singles%20are%20less%20than%2030,length%20of%20over%2030%20minutes.) even a more comprehensive guide.

It could work for Singles but wil be difficult for an EP or Album.

---

<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:** [May 30, 2023, 1:53pm UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/8 "2023-05-30T13:53:04Z")

</div>

And what does list mean in respect to your initial idea?

I would think that you could evaluate the condition as follows:  
Is %\_length\_seconds% greater than 30? -\>Album  
Is the number of total track greater than 6 -\>Album  
Is the number of total tracks greater than 3 -\> EP  
Is the number of total tracks less than 4 -\> single.

If you then include a check whether something is already stored in RELEASETYPE then this will not be the case if you run these action from top to bottom.  
This should cover most cases.

Only those where are 2 very short tracks and one over 30 minutes you get not the right declaration.  
(BTW: 3 single songs with 9:59 would also amount to 30 Minutes or less (29:57) and therefore qualify for an EP. So I think you will not get around a manual check in the end. In my collection real EPs have "EP" in ALBUM. So perhaps that could also help.)

---

<div class="post-metadata">

**Author:** ![may](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@may](https://community.mp3tag.de/u/may)\
**Post date:** [May 30, 2023, 2:12pm UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/9 "2023-05-30T14:12:25Z")

</div>

That looks great thanks!

> Only those where are 2 very short tracks and one over 30 minutes you get not the right declaration.  
> (BTW: 3 single songs with 9:59 would also amount to 30 Minutes or less (29:57) and therefore qualify for an EP. So I think you will not get around a manual check in the end.

It's OK for me I don't mind to manually edit those occasionally.

I used Beets to tag everything using Musicbrainz and Discogs. I am not sure about Musicbrainz but for discogs it is a hit or a miss. I have seen a vinyl release containing EP in the title where the digital version did not. ☹

---

<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:** [June 29, 2023, 2:13pm UTC](https://community.mp3tag.de/t/create-action-field-based-on-length-and-files/61115/10 "2023-06-29T14:13:22Z")

</div>

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