0

I am reading each line of a .txt file in a .batch program using For /f loop. The .txt file contains all the names of the test cases (e.g. ShipmentPostErrorPathXPERF.txt) which I need to read and assign to a variable called testCaseName and pass this to another .cmd program as a parameter and continue in loop until it reads all lines (test cases),

Here is my sample batch file, my problem is when I assign testCaseName=%%A, it only shows assigned to the last line of the file (REST0007-SHIPMETDATA_POST-XPERF_ErrorPath-ShipmentNULLServiceSchedID_TestCase). But when I use echo %%A, it shows all lines as it reads in loop.

Why set testCaseName=%%A in the batch file only reading the last line ?

.batch file:

echo off
cd d:\SWAT
set fileNameXPERF=d:\SWAT\ShipmentPostErrorPathXPERF.txt
for /F "tokens=*" %%A in (D:\SWAT\ShipmentPostErrorPathXPERFxxx.txt) do (
set testCaseName=%%A
echo %testCaseName%
echo %%A
call d:\SWAT\testRunner.cmd %testCaseName%
)

The text file (ShipmentPostErrorPathXPERF.txt):

REST0007-SHIPMETDATA_POST-XPERF_ErrorPath-ShipmentEmptyDockNum_TestCase
REST0007-SHIPMETDATA_POST-XPERF_ErrorPath-ShipmentNULLDockNum_TestCase
REST0007-SHIPMETDATA_POST-XPERF_ErrorPath-ShipmentInvalidDockNum_TestCase
REST0007-SHIPMETDATA_POST-XPERF_ErrorPath-ShipmentEmptyServiceSchedID_TestCase
REST0007-SHIPMETDATA_POST-XPERF_ErrorPath-ShipmentNULLServiceSchedID_TestCase
Jamil Rahman
  • 345
  • 1
  • 6
  • 18

0 Answers0