File List (additional text on seperate line)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sark
Posts: 7
Joined: 21 Feb 2020 07:37

File List (additional text on seperate line)

#1 Post by sark » 31 Aug 2021 03:28

Hi all.

I have a simple bat file that generates a list of files contained within a folder (below).

Code: Select all

(for %%f in (*.*) do @echo %%f) > list.txt 
I can add text before or after the second %%f tag, to add text before or after the file name in my list, but I would like to add some text on a seperate line before the file name (example below). How would I achieve this.

Text Here
file1.txt
Text Here
file2.txt
Text Here
file3.txt

Any advice much appreciated.

Mark
Last edited by sark on 31 Aug 2021 15:52, edited 1 time in total.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: File List (additional text on seperate line)

#2 Post by aGerman » 31 Aug 2021 11:38

Code: Select all

>"list.txt" (for %%f in (*.*) do @echo Text here&echo %%f)
Steffen

sark
Posts: 7
Joined: 21 Feb 2020 07:37

Re: File List (additional text on seperate line)

#3 Post by sark » 31 Aug 2021 15:51

Thanks for that. It,s appreciated.

Mark

Post Reply