I´m facing following little issue - google couldn´t solve it this time...

I have a string like this:
Code: Select all
SET var1=\folder1\...\folderN\[ApplicationName]\[Environment]\
Now I need to extract the string [ApplicationName] from this variable and set it into var2.
I am able to extract [Environment] by cutting this string from left to right with this code:
Code: Select all
rem ================================================== =========================
rem Pfad soweit zerlegen bis nur noch die Environment vorhanden ist
rem ================================================== =========================
:anfang
rem ================================================== =====
rem %TeilPfad% wird von links nach rechts bis zum nächsten "\" beschnitten
rem ================================================== =====
SET TeilPfad=%TeilPfad:*\=%
echo %TeilPfad%
rem ================================================== =====
rem Wenn TeilPfad keinen "\" mehr enthält stop - ansonsten weiter beschneiden
rem ================================================== =====
IF not "%TeilPfad%"=="%TeilPfad:*\=%" GOTO :anfang
SET Environment=%TeilPfad%
To extract [ApplicationName] I would need the function
Code: Select all
SET TeilPfad=%TeilPfad:*\=%
to work the other way around, from right to left... something like this (doesn´t work!!):
Code: Select all
SET TeilPfad=%TeilPfad:\*=%
as I know that there is a specific number of \ behind [ApplicationName].
Some ideas?
Cheers