Copy with carriage return Batch files

Solved
ismail.bensikali Posted messages 5 Status Member -  
ismail.bensikali Posted messages 5 Status Member -
Hello,

I am looking to remove lines that start with "average" from the CSV files and write those lines into a results file; here is what I have found so far:

FOR %%i IN (0,1,9) DO (
@ set meth=%%i
FOR %%j IN (0,1,3) DO (

set it=%%j
findstr "^average" Methode_!meth!_!it!_PSNR.csv >> Resultat.csv
)
)

The result is in the form:
average 36.146590average 36.146590average 36.14659

The problem is that I want to have a result like this:
36.146590
36.146590
36.14659
that is, each result on a separate line; so I added echo.>>Resultat.csv after each iteration and it works well;
I was wondering is there another method to copy the lines and create a newline at the same time?

Thank you for your help.

3 answers

  1. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
     
    You can create a temporary file, to test:
    (type Methode_!meth!_!it!_PSNR.csv & echo.) > %TMP%\fichierxxxx findstr "^average" %TMP%\fichierxxxx >> Resultat.csv 
    1
    1. ismail.bensikali Posted messages 5 Status Member
       
      Hi,

      Thank you for your help Dubcek, it's working great :D
      0
  2. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659
     
    hello
    if average is on the last line, there's no line break at the end of the line.
    either do as you do, or add a line break to the csv files.
    0
  3. ismail.bensikali Posted messages 5 Status Member
     
    Hello

    Thank you dubcek for your reply, the problem is that the csv files containing the "average" values are generated automatically by another command (VQM.exe) and they have a standard format so I cannot modify them.

    Thanks.
    0