Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
Help me in this issue
@echo on
set Path=C:\Temp.txt
for /f "eol=; tokens=1 delims=" %%i in (%Path%) do (set /a no=%%i+1)
echo First %no%
set no=1
echo %no%> %Path%
for /f "eol=; tokens=1 delims=" %%i in (%Path%) do (set /a no1=%%i+1)
echo Final %no1%Here I am trying to read a number from file and after that trying to set it as 1.
But its setting as "ECHO is on".I cant find the reason for it.
set no=1
echo %no%> %Path%Please help me out in this issue
You shouldn't use a variable called "path" path is a system variable that tells the cmd where to look for executable files like find ect. For a list of variables that are not a good idea to use start a new cmd prompt and type in "set". In general terms everything to the left of the "=" should probably not be used.
Now your actual problem may be further down the line, perhaps in the text file. What is in the text file? You need to give an example to make things easier.
Another problem that springs to mind is this line:
echo %no%> %var%
Obviously you don't want a trailing space but since you variable ends in a number cmd may be interpreting your variable as handle redirection. Try this instead:
>%var% echo %no%
I change the variable because of what I mentioned above.
Report Offensive Follow Up For Removal
echo ^2>num.txt
set /p no_1st=<num.txt
set /a no_1st+=1echo 1 >num.txt
set /p no_final=<num.txtset no
1> and 2> is std-out & std-err redirection
Report Offensive Follow Up For Removal
![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |