BAT file to read and copy bottom 16 lines from a text file to another one?

前端 未结 3 2062
庸人自扰
庸人自扰 2020-12-12 02:30

I need to copy the bottom 16 lines from a text file to another text file. I need to do this procedure for all clients. At the client\'s location the text file will be common

3条回答
  •  清歌不尽
    2020-12-12 03:19

    I adapted this useful code to append together 51 files and retain the 12 line header of the first file as follows:

    REM Append 51 files and retain 12 line header of first file
    REM  ------------------------------------------------------
    
    REM Set number of files to combine    
    set Nmbrfls=51   
    
    REM copy the first file with the header 
    copy file_1.txt combined.txt
    
    REM Loop through the other 50 files (start at #2) appending to the combined
    REM file using a temporary file to capture all but the the 12 header lines
    REM than append the temporary file to the combined on each loop
    
    for /l %%i in (2,1,%Nmbrfls%) do (
    more /e +13 file_%%i.txt > temp.txt
    copy /b combined.txt + temp.txt combined.txt
    del temp.txt
    )
    

提交回复
热议问题