0

I have a text file with no. of file formats. I want to print those file names to one text file one by one. Problem here is as soon as it check second file format name and try to write in text file, it will erase the first record info.Here is what I have return

@ECHO OFF
setlocal enableDelayedExpansion
SET "formats=.css.js.jsp."
FOR /F "delims=#" %%A in (demo.txt) do (
   IF "!formats:%%~xA.=!" neq "!formats!" (
     %%~nxA > output.txt
   ) ELSE (
     ECHO Incorrect file format
   )
) 
mas.morozov
  • 2,666
  • 1
  • 22
  • 22
user2918831
  • 455
  • 1
  • 6
  • 9

1 Answers1

0

Just use >> redirection.

%%~nxA >> output.txt

It will append redirected output to the end of your file, instead of cleaning the file before redirecting output there.

mas.morozov
  • 2,666
  • 1
  • 22
  • 22
  • 2
    `>>output.txt echo(%%~nxa` <--- You probably want an echo command too, and swapping the redirection to the front allows you to eliminate the trailing space, and also the `(` in the echo command protects it from some character combinations. – foxidrive Oct 28 '13 at 09:56