# Define string by contents of a tag field

**URL:** https://community.mp3tag.de/t/define-string-by-contents-of-a-tag-field/12093
**Category:** Support
**Created:** [June 4, 2011, 12:13pm UTC](https://community.mp3tag.de/t/define-string-by-contents-of-a-tag-field/12093 "2011-06-04T12:13:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sojourner](https://community.mp3tag.de/user_avatar/community.mp3tag.de/sojourner/32/348_2.png) [@Sojourner](https://community.mp3tag.de/u/Sojourner)
#### Post date: [June 4, 2011, 12:13pm UTC](https://community.mp3tag.de/t/define-string-by-contents-of-a-tag-field/12093/1 "2011-06-04T12:13:03Z")

</div>

Firstly I apologise if this has already been answered - I've done some searches but found no answer.

I want to delete the artist name in the filename (the filename contains both the artist name and the track title, I already have the artist name in the Artist tag field).

I've tried creating:

Action: Replace: _Field_=\_FILENAME, _Original_=%artist%, _Replace with_=blank

Action: Replace: _Field_=\_FILENAME, _Original_=%ARTIST%, _Replace with_=blank

Action: Format Value: _Field_=\_FILENAME, _Format String_=$regexp(filename,%artist%,"") which just results in the name of the file being changed to "filename".

I want to use the contents of the Artist tag field to define what gets removed from the filename. I assume I need to define a string using the contents of the Artist tag field, get mp3tag to find that string in the filename, then delete it from the filename. This is what I'm attempting to do in the above examples.

I'd be very grateful for advice on how to do this, or referral to an existing thread.

---

<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: [June 4, 2011, 12:21pm UTC](https://community.mp3tag.de/t/define-string-by-contents-of-a-tag-field/12093/2 "2011-06-04T12:21:07Z")

</div>

Use  
Action: Format Value  
Field: \_FILENAME  
Format string: $replace(%\_filename%,%artist%,)

---

<div class="post-metadata">

### Author: ![Sojourner](https://community.mp3tag.de/user_avatar/community.mp3tag.de/sojourner/32/348_2.png) [@Sojourner](https://community.mp3tag.de/u/Sojourner)
#### Post date: [June 4, 2011, 12:36pm UTC](https://community.mp3tag.de/t/define-string-by-contents-of-a-tag-field/12093/3 "2011-06-04T12:36:01Z")

</div>

That was quick! Thank you very much for your help - so I should have used $replace in the Format Value action, and I missed out the "%" & "\_" around filename to make it contents-of-filename.

Thank you again.

---

<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: [February 9, 2026, 12:23pm UTC](https://community.mp3tag.de/t/define-string-by-contents-of-a-tag-field/12093/4 "2026-02-09T12:23:08Z")

</div>


