# Problem parsing a string with scripting functions

**URL:** https://community.mp3tag.de/t/problem-parsing-a-string-with-scripting-functions/66747
**Category:** Support
**Created:** [December 5, 2024, 10:00pm UTC](https://community.mp3tag.de/t/problem-parsing-a-string-with-scripting-functions/66747 "2024-12-05T22:00:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Sexycowboy32](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/35a633/32.png) [@Sexycowboy32](https://community.mp3tag.de/u/Sexycowboy32)
#### Post date: [December 5, 2024, 10:00pm UTC](https://community.mp3tag.de/t/problem-parsing-a-string-with-scripting-functions/66747/1 "2024-12-05T22:00:19Z")

</div>

Hi resourceful people,

I'm struggling a bit with an action.  
My files are organised in folders with a release ID and a subsequent version ID  
For example a release with the ID 12345 and a version ID of 012 would be in a folder named 12345012.

When executing the action I would like it to take the `%_directory%` name, minus the last 3 digits, and tag it to release\_id.  
In the same action group it takes the last 3 digits and tag it to version\_id.

I have tried a few different scripting functions, but I can't get it to work properly.  
When there's only one file it works as intended, but when theres more than one, it fails.  
If there is more than one file it continues from the previous file, like:

0101:  
release\_id: 12345  
version\_id: 014

0102:  
release\_id: 12  
version\_id: 345

I would of course like them all to be tagged as 0101.

My scripting functions:  
release\_id:  
`$sub($len(%_directory%),$right(%_directory%,3))`

version\_id:  
`$right(%_directory%,3)`

I think version\_id works properly as long as release\_id also works.  
I have tried a lot of different functions for release\_id by now, and it’s driving me nuts.

Can anyone help me sort this out?

---

<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: [December 5, 2024, 10:17pm UTC](https://community.mp3tag.de/t/problem-parsing-a-string-with-scripting-functions/66747/2 "2024-12-05T22:17:31Z")

</div>

to split the data from \_DIRECTORY named 12345014 into release\_id and version\_id try an action of the type "Guess value"  
Source format: `$regexp(%_directory%,(\d+)(\d\d\d),$1==$2)`  
Guessing pattern: `%release_id%==%verion_id%`

---

<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: [January 4, 2025, 10:18pm UTC](https://community.mp3tag.de/t/problem-parsing-a-string-with-scripting-functions/66747/3 "2025-01-04T22:18:18Z")

</div>

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