none
executing line 1 in file y against line 1 in file z RRS feed

  • Question

  • I am trying to run a batch file like below:

    @echo off
    For /f %%i IN (y.txt) do (
    For /f %%j IN (z.txt) do  (
    echo %%i %%j
    )
    )

    However I want that line 1 in file y to be echoed only with line 1 in file z. How can I accomplish this?

    I don't want line 1 in file y to be echoed against all lines in file z. It should only echo line 1 in file y with  line 1 in file z, line 2 in

    file y with  line 2 in file z and so on for all the lines.



    • Edited by Admin55 Friday, August 17, 2018 2:55 PM
    • Moved by Bill_Stewart Wednesday, December 12, 2018 5:22 PM This is not "debug/fix/rewrite my script for me" forum
    Friday, August 17, 2018 2:55 PM

All replies

  • Batch is obsolete.  Use PowerShell

    $y = Get-Content y.txt
    $z = Get-Content z.txt
    
    for($i = 0;$i -lt $y.Count;$I++){
          Write-Host $y[$i] $z[$i]
    }
    


    \_(ツ)_/

    Friday, August 17, 2018 4:01 PM