|
Answer» I have many environment variables with value like testfilename.txtsomethingelse. The length of somethingelse is not constant and neither the part before .txt for each of those variables.
I want to remove the string before .txt or the string after .txt of all those variables.
Is there a way to use wildcard to extract the string after .txt?
Can I do somthing like SET a=%b:*.txt=%
I know this is not correct, would any experts give some ideas ? Provided the .txt stays constant, this should work:
Code: [SELECT]@echo off for /f "tokens=1-2 delims=." %%a in ("testfilename.txtsomethingelse") do ( set var2=%%a set var=%%b ) set var=%var:~3% echo %var2% %var%
For a more robust solution, TRY Windows Script
Hope this helps. 8-)
Note: you can replace testfilename.txtsomethingelse with any environment variable (SURROUNDED by %); keep the quotes.You are really cool 8-)
THANKS very much!
|