0

file a.txt

AS02032849
AS02037866
AS04444444
AS02040196
AS06666666  

file c.txt

1111111111

I need to append the content of file c.txt in a.txt after the line 3.

output of temp.txt

AS02032849
AS02037866
AS04444444
1111111111
AS02040196
AS06666666

script

@ECHO OFF
set /a counter=0
(
  FOR /F "tokens=*" %%A IN (a.txt) DO (
  set /a counter=%counter%+1   
  ECHO %%A
  echo.%counter%
    IF %counter% EQU 3 (
      TYPE c.txt
    )
  ) 
) >temp.txt
pause
Compo
  • 36,585
  • 5
  • 27
  • 39
Munu
  • 103
  • 5
  • 15
  • Welcome to Stack Overflow. We are not a script writing service. We expect users to tell us what they have tried so far (including any scripts they are using) and where they're stuck so that we can help with specific problems. Questions that only ask for scripts are too broad and are likely to be [put on hold or closed](http://stackoverflow.com/help/closed-questions). Please read [ask]. **Hint**: use some (nested) [`FOR` loop(s)](https://ss64.com/nt/for.html). – JosefZ Oct 16 '17 at 05:57
  • you need [delayed expansion](https://stackoverflow.com/a/30284028/2152082). Note: to force `echo` to write to screen (for debugging like `echo.%counter%`) during a general redirection, you can `>con echo. !counter!` Another hint: `set /a counter +=1` increases counter by one. – Stephan Oct 16 '17 at 14:50

0 Answers0