Basically, the script I have now can copy the top seven lines of each game's box score (these are standard .txt files) and put them into a separate .txt file. The script then further distills those seven lines down to a line score for the game. The result looks like this:
TEAM 1 2 3 4 5 6 7 8 9 R H E DATE/TIME
Dragons 0 0 1 0 0 0 0 0 0 1 5 0 04-28-14
Redbirds 0 0 0 0 0 0 0 0 0 0 2 0 9:14pm
The advantage of this for me is that the above line score can import perfectly into Excel and I can do my record-keeping of game results quickly and efficiently.
BUT . . . right now, my script just does one game. I need the script to be able to process several games at once. Ideally, it would:
1. Scan all .txt files in a folder I specify AND its subfolders, and copy the top seven lines of each to an output text file;
2. It would write the output file so that each line score was prefaced by the folder name it is contained in, text file name, and finally the line score.
The folder names are all in the format of the two teams who played, with an @ symbol in between, i.e., ACA @ MID.
So, ultimately, you would end up with a .txt file that had something that looked like this:
ACA @ MID: GAME1.txt:
(line score line 1, no parens)
(line score line 2, no parens)
(line score line 3, no parens)
ACA @ MID: GAME2.txt:
(line score line 1, no parens)
(line score line 2, no parens)
(line score line 3, no parens)
. . . etc. etc.
I've included the script I have now that works to boil down the line score for one game. I am no expert by any means, so it probably is pretty clumsily written, but here it is:
Code: Select all
@setlocal enableextensions enabledelayedexpansion
@echo off
set input_file=GAME1.txt
cls
set /a out_num=1
set /a line1=1
set /a line2=2
set /a line3=3
set /a line4=4
set /a line5=5
set /a line6=6
set /a times=0
:start_find
cls
echo.
echo %out_num%
echo.
echo %line1%
echo %line2%
echo %line3%
echo %line4%
echo %line5%
echo %line6%
set lines=%line1% %line2% %line3% %line4% %line5% %line6%
set curr=1
for /f "delims=" %%a in ('type %input_file%') do (
for %%b in (!lines!) do (
set !curr!=curr
if !curr!==%%b echo %%a >>output_%out_num%.txt
)
set /a "curr = curr + 1"
)
findstr /v "ECHO BOXSCORE" output_1.txt > outfile.txt
del output_1.txt
Thanks for any help.