I am trying to do some string comparison and extraction in a batch file. The operation takes place on a set of folder names from a SVN repository.
for /f %%f in ('svn list https://dev_server/svn/product/branches') do (
set folder=%%f
echo Folder: %folder%
:: get substring from %folder% starting at 0 with a length of %length%
:: if this substring is equal to %folderStart% then get substring from %folder% starting at position %length%
)
There are a couple of problems here:
Does anyone have an idea how I could implement the functions in the commented section in the code above?
Dynamic substring is easy with delayed expansion.
setlocal enableDelayedExpansion
set "string=1234567890"
::using a normal variable
set len=5
echo !string:~0,%len%!
::using a FOR variable
for /l %%n in (1 1 10) do echo !string:~0,%%n!
It can also work with search and replace
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With