Add text to beginning and end of each line using batch/cmd
13,223
Create a batch file e.g:
script.bat:
@echo off
for %%i In (*.txt) DO echo %CD%\%%i string
then simply run script.bat from the directory where you want to list the files and append the string
Related videos on Youtube
Author by
csg
Updated on September 18, 2022Comments
-
csg over 1 year
What I'd like to achieve in the end is to generate a text file that lists all *.txt files in the current directory with the path appended to the beginning of the filenames, and some other string after the filenames.
ie.
C:\path\first.txt string C:\path\second.txt string C:\path\third.txt string
As of now all I can think of is to use
dir /b *.txt
and some sort of regex code to append the strings, but unsure how to. If it matters, the path and string at the end are the same for all lines.
Thank you!