How to replace encode html in _ by frontmatter url

I have a structure like:

content
 + abc
   + def 
     + ghi 
       + xyz
         + 1
         + 2
     + jkl
       + xyz
         + 3
         + 4

and I want to get:

public
 + abc
   + ghi 
     + 1
     + 2
   + jkl
     + 3
     + 4

I am able to get this by using the following in frontmatter:

in _index.md in ghi and jkl:

url: /:sections[:1]/:contentbasename

and in 1, 2, 3, 4:

url: /:sections[:1]/:sections[2:3]/:contentbasename

So it works fine! However with contentbasename the special characters like ( are encode as _, but with eg. :sections[2:3] is encode like %28. How can I avoid this?

Please present your content structure like this;

content/
├── posts/
│   ├── _index.md
│   ├── post-1.md
│   ├── post-2.md
│   └── post-3.md
└── _index.md

That will help us to understand which directories are sections.

You can use the tree command, available on Windows, Linux, and macOS.

I solved it now by renaming the directories. I will come back with some examples to make clear my problem. I don’t think the directory structure is important.