Batch file to add line to top and bottom

Asked By 0 points N/A Posted on -
qa-featured

I'd like to know how to add line to top and bottom of data in a file.

Can you help me?

SHARE
Answered By 5 points N/A #161776

Batch file to add line to top and bottom

qa-featured

Hi there,

I can provide you with commands that will definitely going to add lines at top and bottom of your Batch data File,

Back up your old file and use these commands,

 

@echo off

echo ***New top line*** > temp.txt

for /f "tokens=*" %%a in (yourfile.txt) do (

  echo %%a >> temp.txt)

echo ***New bottom line*** >> temp.txt

echo y|del yourfile.txt

rename tempt.txt yourfile.txt

 

That should work out your problem,

If above given command does not works then use following command which is relatively shorter

 

@echo off
echo ***New top line*** > temp.txt
type myfile >> temp.txt
echo ***New bottom line*** >> temp.txt
move /y temp.txt myfile

 

Hope that works!!

Related Questions