One way to do this is to use this line in the template to replace
(/.+?)(/.+?){2}(/\S+)
And use this in your template to replace it
$1/new-folder$3
From the line:
/folder/subfolder-1/subfolder-2/subfolder-3
(/.+?)
will match /folder
as $ 1
(/.+?){2}
will match /subfolder-1/subfolder-2
as $ 2 (not used)
(/\S+)
will match anything that is not space, in this case /subfolder-3
as $ 3
Leaving you in the room to insert a new folder between them.
source share