Adding Filename to Existing File

April 19, 2010 at 13:21:13
Specs: Windows XP
I have a DOS batch file which uses the findstr command and piping to output the result of the findstr to a file. Once this file is created, within the same batch file, I want to add the full path and filename to this results file before the batch file completes. The findstr command I'm using is..findstr /i /n /g:"c:\winlc\KEYS_IN1.TXT" %1 >> "C:\WinLC\%~n1.tmp" and after that I've tried the following, but it doesn't seem to work...for /F "delims=" %%j in ("C:\WinLC\%~n1.tmp") do @echo.%1 %%j >> "C:\WinLC\%~n1.tmp1". Any help would be greatly appreciated.

See More: Adding Filename to Existing File

Report •

April 19, 2010 at 13:48:14
>> C:\WinLC\%~n1.tmp echo.%~F1

Helping others achieve escape felicity


Report •

April 19, 2010 at 15:18:55
Thanks, M2...I'll give this a try tomorrow. I really appreciate your reply. If this works, it will really help me.


Report •

April 20, 2010 at 07:01:52
Hi M2,
I checked the solution this morning, and except for one small issue, it worked fine... I'm getting a message from FINDSTR which I don't understand.. I'm including the output so you can see it..

FINDSTR: Cannot open echo.F:\SASProg\Clients\proj317\QC\Analysis Data\SAS Code\Prog\ECG.log

After that error message, the rest of the file seems fine. Is there any way to suppress that message?

Report •

Related Solutions

Ask Question