Need help with specific line text in a batch

February 14, 2011 at 13:57:30
Specs: Windows XP
What I have is multiple XML files. Each individual files on the 7th line from the bottom has the parameter or text line that I need to copy to a new, separate text file.


in my directory, I have the following files:

Each of those files are of varying length. Each has a result on the line that is 7th from the bottom on the file. I need the file to print the contents of that line from each of the individual XML's to a single text file called results.txt

I am not very good with this type of stuff, but my boss really needs it and I am the only one in the office this week. Please help

See More: Need help with specific line text in a batch

Report •

February 14, 2011 at 22:24:53
First we crawl, then we walk. See if this gets the needed line.

:: ==========================================
:: get 7th line from bottom of xml
:: sevenbot.bat Tue 15-02-2011 12:59:59.28
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=1* delims=[]" %%a in ('find /v /n "" ^< myfile') do (
set %%a=%%b
set BOT=%%a
set /a S=BOT-6
> newfile echo.!%S%!

Life is too important to be taken seriously.


Report •

February 15, 2011 at 01:15:15
Replace \My_Folder with your folder path and you are done

@echo off & setlocal EnableDelayedExpansion
cd \My_Folder
type nul > results.txt
for %%i in (*.xml) do (
  for /F %%j in ('type "%%i" ^| find /C /V ""') do set row=%%j
  set /A row-=6
  set cnt=1
  for /F "delims=" %%j in ('type "%%i"') do (
    if !cnt! equ !row! (
      set line=%%j
      echo.!line!>> results.txt
    set /A cnt+=1
echo.& echo.  Processing completed

Report •
Related Solutions

Ask Question