Sign in with
Sign up | Sign in
Your question

Batch file problem in windows

Tags:
  • Windows
Last response: in Windows 2000/NT
Share
September 7, 2012 11:49:22 AM

Hello,
I'm trying to increment a number in a batch file and I'm sure its something simple. The counter wont increment. I get the same number in every file.

rem stage 02
rem
set /a counter=20213
echo %counter% begin >>Mikey.txt
rem
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
for /F "tokens=1" %%c in (File.card2) do (
@echo.|set /p="cscript.exe wmcmd.vbs -vdevice ">%%c.bat
findstr /i "Video" %%c > %%c.av
for /F "tokens=1-4" %%f in (%%c.av) do @echo.|set /p="%%f " >>%%c.bat
@echo.|set /p=" -adevice " >>%%c.bat
findstr /i "Audio" %%c > %%c.aa
for /F "tokens=1-4" %%d in (%%c.aa) do @echo.|set /p="%%d " >> %%c.bat
@echo.|set /p=" -maxpacket 1400 -author %%c -description %%c -broadcast %counter% ">> %%c.bat
@echo.|set /p=" -loadprofile f4.prx -duration 86400 ">>%%c.bat
set /a counter=%counter%+1)
del /q *.aa
del /q *.av
del /q *.card
endlocal

More about : batch file problem windows

September 7, 2012 1:36:51 PM

I was on the right track and I found the error of my ways.


rem stage 02
rem
set /a counter=20213
echo %counter% begin >>Mikey.txt
rem
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
for /F "tokens=1" %%c in (File.card2) do (
set /a counter+=1
@echo.|set /p="cscript.exe wmcmd.vbs -vdevice ">%%c.bat
findstr /i "Video" %%c > %%c.av
for /F "tokens=1-4" %%f in (%%c.av) do @echo.|set /p="%%f " >>%%c.bat
@echo.|set /p=" -adevice " >>%%c.bat
findstr /i "Audio" %%c > %%c.aa
for /F "tokens=1-4" %%d in (%%c.aa) do @echo.|set /p="%%d " >> %%c.bat
@echo.|set /p=" -maxpacket 1400 -author %%c -description %%c -broadcast !counter! ">> %%c.bat
@echo.|set /p=" -loadprofile f4.prx -duration 86400 ">>%%c.bat)
del /q *.aa
del /q *.av
del /q *.card
endlocal

m
0
l
September 18, 2012 12:05:50 AM

It was the set counter?
m
0
l
September 25, 2012 3:59:45 PM

ktownmike said:
It was the set counter?

The answer was the ! on either side of counter i.e. !counter!
m
0
l
!