Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
miskox
- Posts: 666
- Joined: 28 Jun 2010 03:46
#1
Post
by miskox » 16 Apr 2012 05:15
Ok, title is probably not what it should be - I will change it if I remember anything else.
I have this problem:
Code: Select all
@echo off
set /a counter=0
set var2=sometextetc
:0
set var1=%var2:~%counter%,1%
set /a counter=counter + 1
echo %var1%
if %counter% leq 10 goto :0
REM above we make sure string length is correct - this is not important here
This does not work. What should be done? I prefer a solutoin without a delayed expansion.
Thanks,
Saso
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 16 Apr 2012 05:42
if you don't have ^ characters in your string:
Code: Select all
call set var1=%%var2:~%counter%,1%%