# How to tag based on filename but limit the number of characters used for a field?

**URL:** <https://community.mp3tag.de/t/how-to-tag-based-on-filename-but-limit-the-number-of-characters-used-for-a-field/45786>\
**Category:** Support\
**Created:** [July 1, 2019, 3:34am UTC](https://community.mp3tag.de/t/how-to-tag-based-on-filename-but-limit-the-number-of-characters-used-for-a-field/45786 "2019-07-01T03:34:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jplank](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/c5a1d2/32.png) [@jplank](https://community.mp3tag.de/u/jplank)\
**Post date:** [July 1, 2019, 3:34am UTC](https://community.mp3tag.de/t/how-to-tag-based-on-filename-but-limit-the-number-of-characters-used-for-a-field/45786/1 "2019-07-01T03:34:01Z")

</div>

I'm wondering if someone can help with a basic problem I'm having. The filenames of my mp3s are something like "01Like a Rolling Stone". Normally, I would use Filename -\> Tag and set it using %track%%title%, but the problem I have is that when I use this, MP3Tag tries to set the track equal to "01Like" (I think because there's no space between them). Is there a way to tell MP3Tag to use only the first two characters for the track field?

---

<div class="post-metadata">

**Author:** ![poster](https://community.mp3tag.de/user_avatar/community.mp3tag.de/poster/32/4881_2.png) [@poster](https://community.mp3tag.de/u/poster)\
**Post date:** [July 1, 2019, 4:29am UTC](https://community.mp3tag.de/t/how-to-tag-based-on-filename-but-limit-the-number-of-characters-used-for-a-field/45786/2 "2019-07-01T04:29:36Z")

</div>

Define an action group (`ALT-6`):  
Type: Format Value

1. Action:  
Field: TRACK  
Format String: `$num(%_filename%,2)` **or** `$left(%_filename%,2)`

2. Action:  
Field: TITLE  
Format String: `$cutleft(%_filename%,2)`

---

<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:** [July 1, 2019, 5:17am UTC](https://community.mp3tag.de/t/how-to-tag-based-on-filename-but-limit-the-number-of-characters-used-for-a-field/45786/3 "2019-07-01T05:17:31Z")

</div>

> [@jplank](#):
>
> 01Like a Rolling Stone

Or if you like a regular expression better:  
Format value for TRACK:  
Format string: `$regexp(%_filename%,^(\d+).*,$1)`

Format value for TITLE:  
Format string: `$regexp(%_filename%,^\d+,)`

---

<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 9, 2024, 7:08am UTC](https://community.mp3tag.de/t/how-to-tag-based-on-filename-but-limit-the-number-of-characters-used-for-a-field/45786/4 "2024-06-09T07:08:39Z")

</div>

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