# How to compare actual track length with length from Tag Source?

**URL:** <https://community.mp3tag.de/t/how-to-compare-actual-track-length-with-length-from-tag-source/61831>\
**Category:** Support\
**Created:** [August 16, 2023, 4:14am UTC](https://community.mp3tag.de/t/how-to-compare-actual-track-length-with-length-from-tag-source/61831 "2023-08-16T04:14:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitskream](https://community.mp3tag.de/user_avatar/community.mp3tag.de/bitskream/32/7247_2.png) [@bitskream](https://community.mp3tag.de/u/bitskream)\
**Post date:** [August 16, 2023, 4:14am UTC](https://community.mp3tag.de/t/how-to-compare-actual-track-length-with-length-from-tag-source/61831/1 "2023-08-16T04:14:06Z")

</div>

I'm finding myself defeated by a tagging challenge that I hope someone here can assist with. I have performed some batch tagging via source scripts, which is remarkable accurate, but also occasionally mis-matches. In order to help identify the mismatched tracks, I wish to compare the known track length with the "Time\_Check" field that came from the Tag Source; in this case Beatport. Good matches usually have an accuracy of +/- 2-3 seconds for these values. Consequently. I would like to create a calculated field value to help identify any tracks whose variance between these two fields is greater than 3 seconds. I cannot find a suitable combination of functions to accomplish this, seemingly simple, task. Anyone have a trick/method that I could employ to accomplish this? Thanks.

---

<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:** [August 16, 2023, 5:15am UTC](https://community.mp3tag.de/t/how-to-compare-actual-track-length-with-length-from-tag-source/61831/2 "2023-08-16T05:15:00Z")

</div>

> [@bitskream](#):
>
> create a calculated field value

The arithmatic functions are described in the documentation:

> **[Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/#arithmetic-functions)**
>
> Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

As you do not say what the data in

> [@bitskream](#):
>
> Time\_Check

looks like, it is hard to go into more details than  
`$sub(%_length_seconds%,%time_check%)`  
would return the difference.  
It could be that you have to transform %time\_check% into seconds as well:  
`$add($mul($num(%_length%,1),60),$num($right(%_length%,2),2))`  
(this works only for files of a length shorter than 1 hour)

> [@bitskream](#):
>
> I would like to create a calculated field value

I would not clog up the tags but use a filter with GREATER or LESS

---

<div class="post-metadata">

**Author:** ![bitskream](https://community.mp3tag.de/user_avatar/community.mp3tag.de/bitskream/32/7247_2.png) [@bitskream](https://community.mp3tag.de/u/bitskream)\
**Post date:** [August 16, 2023, 4:43pm UTC](https://community.mp3tag.de/t/how-to-compare-actual-track-length-with-length-from-tag-source/61831/3 "2023-08-16T16:43:58Z")

</div>

Great suggestions. I'll be experimenting with these to see what works well/best. Much appreciated!

EDIT:

That was exactly the hint I needed to do this, so many thanks.

First, I created a Calculated field column to show the variance:

```auto
$sub(%_length_seconds%,$add($mul($num($meta(_TIME_CHECK),1),60),$num($right($meta(_TIME_CHECK),2),2)))

```

Then, I added a filter to show only items whose variance was greater than 3 or less than -3. NB. I could really use an $abs() function here, but don't see documentation for one anywhere.

```auto
$sub(%_length_seconds%,$add($mul($num($meta(_TIME_CHECK),1),60),$num($right($meta(_TIME_CHECK),2),2))) LESS -3 OR $sub(%_length_seconds%,$add($mul($num($meta(_TIME_CHECK),1),60),$num($right($meta(_TIME_CHECK),2),2))) GREATER 3

```

These seem to be solving my initial problem quite well. Many thanks.

---

<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:** [September 15, 2023, 4:44pm UTC](https://community.mp3tag.de/t/how-to-compare-actual-track-length-with-length-from-tag-source/61831/4 "2023-09-15T16:44:13Z")

</div>

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