Automation to add a LF and CR (EOL) to the end of multiple .csv files

The FINDSTR regular expression $ recognizes end of line as the position immediately before a carriage return. So findstr /v $ will only match lines that do not contain a carriage return. You can use this fact to append carriage return/linefeed to only files that need it, without having to rename any files.

The following one liner from the command line is all you need:

for /f "eol=: delims=" %F in ('findstr /m /v $ *.csv') do @(echo()>>"%F"

Double up the percents if you put the command within a batch script.


This will search all .csv file names for the string _fixed, and on any who fail to have it, will insert a blank line and rename it. Of course replace the pathToWherever with the correct path for you, and the /s option can be added to allow searching in subfolders in the named path too.

@echo off
for /r "C:\pathToWherever\" %%G in (*.csv) do (
    echo %%G | findstr /c:"_fixed" || (
        echo:>>%%G
        ren "%%G" "%%~nG_fixed.csv" 
    )
)