I have written below script:
@echo off
setlocal EnableDelayedExpansion
REM Collect source filenames from C:\Files and load into C:\doc.txt
dir C:\sources\Sourcefiles /b /a-d > C:\sourcefilenames.txt
REM fetch count of source files and store into variable count
For /F %%I in ('call C:\count.bat ') Do Set count=%%I
REM loop "count" number of times and echo temp.txt value
FOR /L %%A IN (1,1,%count%) DO (
REM call line.bat to fetch line 1,line 2 and so on of sourcefilenames.txt for each loop
call line.bat %%A>C:\temp.txt
set /p var=<C:\temp.txt
echo var:%var% ----------> returns previous run value
type C:\temp.txt ----------. returns current value of temp.txt
)
Basically what i am trying to do out of the above script is: I am creating a variable(var) from the content of temp.txt(data in temp.txt will change for each time loop runs) to be used in multiple loops.
But the problem i am facing is : Echo var is:%var% command returning me previous run value not temp.txt current content.whereas command "type C:\temp.txt" returning me temp.txt current content. (Note: if i have called/created variable "var" from some other script it returns me that previous value else it returns Null)
Your help/guidance on above issue is really appreciated. Thanks