0

I would like to save the output of a list of files to a file (by using a Windows batch file). I know I can do this by the command dir /b *.* > start.txt, but for each line in the file "start.txt" I would like to add @@ in front of the file name. So the contents of start.txt should be:

@@filename1  
@@filename2
...

I know by using the command Echo I can add text. But how can I do this for each line that is written to the file?

rarejoep
  • 1
  • 1

1 Answers1

0

Use the for parser on the output of dir:

(for /f "usebackq" %%l in (`dir /b \`) do echo @@%%l) > start.txt

Note the %% escaping - this is required when running inside a .bat/.cmd, which you presumably are.

Jonathan
  • 6,939
  • 4
  • 44
  • 61