Search code examples
windowscommand-linefindstr

findstr is not saving new file as expected


I have used this command, to create a new file after searching for a query using findstr

find /c "Total record count" Movements_*.csv.old   && ( findstr /v /c:"Total record count" Movements_*.csv.old >> result.csv)

This is saving the expected results in result.csv, but Movements_20150317 is added before and after the data like this:

"Movements_20150317.csv.old:AGREEMENT,CURRENCY,MARGIN TYPE,AGREEMENT BRANCH NAME,AGREEMENT BRANCH CIS CODE,NOTIONAL LABEL,IDMovements_20150317.csv.old:"

Please suggest, how can this be removed?

Thanks!!


Solution

  • Try this:

    find /c "Total record count" Movements_*.csv.old   && ( for %a in (Movements_*.csv.old) do @findstr /v /c:"Total record count" "%~a" )>result.csv