Get the name of an archive using macros

Im writing a macro that gets the name of an archive and then rename it to a default name based on the ID of the archive that is inside a table. Im stuck rn because I dont know how to manipulate strings in a macro, I got the whole archive directory, but I would like to have just the name of it, is there a way to do it? I know that something like that can be done using bash script:

grep -o -P '(?<=).*(?=/home)

this command catch whats between "" and "/home". I would like to catch whats between "photos/" and "" cause thats where the name of the archive is.

I you are writing your macros in Basic here is a link to the
Star Basic Programmers Guide
There is a section on strings that shows all the available functions

I didnt find what I need there, theres just ways to catch parts of strings based on predefined values, but Im working on a string that is variable, because it depends on where I have my document and what system Im using, I need something like grep for this.

Then use the shell() funktion to call external grep.
.
But don’t be surprised, if you someday find out that languages like BASIC, C etc. can actually work with variable values since more than 40 years (python is a bit younger).

I think I found another solution not using bash, I’ll share if it works.