add "echo" comand at the begining of every line [solved]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

add "echo" comand at the begining of every line [solved]

#1 Post by abc0502 » 20 Mar 2012 11:50

hi,
i'm trying to add echo command to every line in a file to output ascii image in my batch as a welcome screen, but i have problems with the spaces in the front of every line.

i need to add the echo without losing the spaces at the begining of every line.

here is a sample image begins with spaces:

Code: Select all

                                                    
                         i                       
                    i i i i i i i                 
                 i iiiii   iii iii   i           
              iiiii           iivXBIi             
         i  iMBvi                ijMMb   i       
        i  YMBi                     AMB i i       
          jMM                        iMB iii     
         iMMi          iiivii         zMb iii     
       i MMM           icAbj           MMi i     
      i jMMI           ipvY  ii        BMZ  i     
     i  BMOp         iiiiiiiii         BMM       
     iiiMBbI          iiviYii          WMMi i     
     i cMOnb       i i iiiii i         BBMY       
      ijMttd        i i i              QMMj       
     i tBjiFj         ii i             BWMi       
      ivBiivbi          i i           vBBMi       
     i iWYiiiFi                      inXpM       
      i ZviY                           icB       
       iid Bi                    i   iQiZY i     
      i  CiiBipi               ii  iZAz Q         
       i iS iZii                   vjv Ei         
          iY  viiXi i          iWbvi  Bi         
         i ivi iibBbii       iJdSY  iMi           
          i  iv   ivYjc i  iAXvii  tMi           
              ioi    iiiiiiv     iFM             
                Cii   iiiii   i iPO               
                 iiii  i i   i vWF               
                   ii       iivpv                 
                         i   ii                   
                                               
Last edited by abc0502 on 20 Mar 2012 12:29, edited 1 time in total.

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: add "echo" comand at the begining of every line

#2 Post by !k » 20 Mar 2012 12:00

Code: Select all

set "img=image.txt"

>%img%.cmd (
echo:@echo off
for /f "delims=" %%a in (%img%) do @echo:echo:%%a
echo:pause^>nul
)


abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: add "echo" comand at the begining of every line

#3 Post by abc0502 » 20 Mar 2012 12:14

hi !k thanks for the replay
the batch doesn't work did it work with you

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: add "echo" comand at the begining of every line

#4 Post by abc0502 » 20 Mar 2012 12:19

hi again:)
when i use this:

Code: Select all

@echo off
cls
set "img=image.txt"
for /f "delims=" %%a in (%img%) do echo %%a
pause

it out put the image from the txt file to the cmd window
but i need to put the echo to the file it self
any ideas

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: add "echo" comand at the begining of every line

#5 Post by !k » 20 Mar 2012 12:21

image.txt, img.cmd & image.txt.cmd
http://multi-up.com/671639

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: add "echo" comand at the begining of every line

#6 Post by abc0502 » 20 Mar 2012 12:28

@!k
thanks alot
i didn't realise that the file was on my desktop
i have many files so i didn't notice even the code i didn't notice i thought it will modify the image.txt file
thanks alot it worked from the first time
:D

Post Reply