Basically I have this batch file below, which will return the first x rows from the input .csv file parameter. However, the only issue now is that this batch file will be called several times to create this output file and will keep appending the results to the output file. I can't change the >> to > since this is a for loop and will just keep overwriting a single line into my output file, which is incorrect. Does anyone have any ideas on how to overwrite the output .csv file each time the batch file is run? Thanks.
@echo off if [%1] ==  goto usage if [%2] ==  goto usage call :print_head %1 %2 goto :eof REM REM print_head REM Prints the first non-blank %1 lines in the file %2. REM :print_head setlocal EnableDelayedExpansion set /a counter=0 for /f ^"usebackq^ eol^=^ ^ delims^=^" %%a in (%2) do ( if "!counter!"=="%1" goto :eof @echo>>trimmed.csv %%a set /a counter+=1 ) goto :eof :usage echo Usage: head.bat COUNT FILENAME