home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 40,594 of 42,547   
   Tom Lavedas to Zac   
   Re: appending line of text from file to    
   18 Dec 12 07:26:01   
   
   From: tglbatch@verizon.net   
      
   On Tuesday, December 18, 2012 9:50:22 AM UTC-5, Zac wrote:   
   > Hello, I need help and solution for the following situtation.   
   >   
   > I have two files: source.txt and output.txt   
   > Source.txt file has two lines.   
   >   
   > I need a batch file that does the following:   
   > - Asks the user to enter a number   
   > - Copies the second line from the source.txt file in the output.txt file   
   > as many times as the value entered (each time creating a new row)   
   > - on starting up again does the same thing so that adds a lines below   
   > the existing ones If anyone can help I would be grateful.   
      
   Maybe something like this will do what you want ...   
      
    @echo off   
     if [%1]==[] %0 source.txt output.txt   
     if [%2]==[] %0 %1 output.txt   
     setlocal & set numb=>> %2   
     set /p numb=Enter a number:   
     if not defined numb exit /b 1   
     for /f "skip=1 delims=" %%L in (   
       %1) do echo/%%L > %temp%\_T_ & goto :Next   
    :Next   
     for /l %%N in (1,1,%numb%) do copy /b %2 + %temp%\_T_ > nul   
     del %temp%\_T_   
   __________________________   
   Tom Lavedas   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca