I need to create a Windows batch file that generates a .csv file with three fields for all the files in a directory (minus the batch file itself!).
Fields:
I had a requirement to read the number of lines in two files and output to a csv file.
@ECHO OFF
cd "D:\CSVOutputPath\"
echo Process started, please wait...
echo FILENAME,FILECOUNT> SUMMARY.csv
for /f %%C in ('Find /V /C "" ^< "D:\Trial\Salary.txt"') do set Count=%%C
echo Salary,%Count%>> SUMMARY.csv
for /f %%C in ('Find /V /C "" ^< "D:\Trial\Tax.txt"') do set Count=%%C
echo Tax,%Count%>> SUMMARY.csv
The >
will overwrite the existing content of the file and the >>
will append the new data to existing data