I have a batch file that looks in several .RTF files (file1) for specific info then puts the name of the document in file2. I need to create a comma delimited file (file3) to use in a command line email program to send all the file1's as attachments based on the contents of file2.
The batch file I have creates all file1 and file2 correctly. I have a FOR statement that adds a comma to the end of the document names in file2 and it displays the document name with comma when issuing the ECHO command.
The batch file will output only the last document name/comma it encounters to file3.
How can I get all of the document names in file2 to written to file3 with a comma at the end of each line.
Current output to file3:
7868685425587963.rtf,
Desired output to file3:
7868684496427836.RTF,
786868535408221.RTF,
7868685416423800.RTF,
7868685425587963.rtf,
Script in batch file:
setlocal
del file2.txt
del file3.txt
set comma=,
echo %comma%
rename *.DAT *.RTF,
findstr /m "0097" *.RTF >> file2.txt
for /f %%a In (file2.txt) DO set str=%%a%comma%
echo %str%>> file3.txt
pause
endlocal
I've been trying to figure this out off and on for several weeks and have tried many iterations.
>> file3.txt (for /f %%a In (file2.txt) DO echo(%%a%comma%)
– JosefZ