Hello, i need a windows batch script to prepend (insert to the beginning) to every line of a file:
string to insert:
"hello"
<input.txt>
dos
tips
forum
<output.txt>
hellodos
hellotips
helloforum
Can you suggest a solution?
Thank you,
Yiğit.
Prepending string to each line
Moderator: DosItHelp
Re: Prepending string to each line
What is your real data? Is it a path/filename like in the last example?
Code: Select all
@echo off
for /f "delims=" %%a in (filein.txt) do (
>>"fileout.txt" echo hello%%a
)
Re: Prepending string to each line
hi foxidrive, i am trying to build an ant build.xml to include some files. by your help so far, i could achieve to convert:
/AS/lib/classes/configuration/ApiMessages.xml
into:
<classpath codebase="file:/AS/lib/classes/configuration/" archives="ApiMessages.xml" />
thank you, your code work as i needed. good day.
/AS/lib/classes/configuration/ApiMessages.xml
into:
<classpath codebase="file:/AS/lib/classes/configuration/" archives="ApiMessages.xml" />
thank you, your code work as i needed. good day.
Re: Prepending string to each line
@echo off
FOR /F "delims=" %%G IN (file_names.txt) DO (
set "FILE=%%G"
setlocal enabledelayedexpansion
set "file1=hello!FILE!"
echo !FILE!
echo !file1!>>output.txt
endlocal
)
FOR /F "delims=" %%G IN (file_names.txt) DO (
set "FILE=%%G"
setlocal enabledelayedexpansion
set "file1=hello!FILE!"
echo !FILE!
echo !file1!>>output.txt
endlocal
)