troubleshooting Question

Project for humanity, have 1800 text files to search for numbers, do some math, print results to text file

Avatar of Christopher Minor
Christopher MinorFlag for United States of America asked on
Windows Batch* commandlinePowershell
15 Comments1 Solution47 ViewsLast Modified:
1800 scripts to search like below, that I have created a for humanity, so you can see the need, to be able to do this in bulk. I provided some code code.

SCRIPT
The world (SILENCE TAG="500") as we have created it (SILENCE TAG="500") is a process (SILENCE TAG"250") of our thinking (SILENCE MSEC="1000") It cannot be changed (SILENCE TAG="500") without changing our thinking (SILENCE TAG="1000") ~ Albert Einstein

I need a batch file that can go though all of the files in a folder, search text files for numbers inside these tags: (SILENCE TAG"500") then divided them by 2, and store the results into a variable like sum1. Copy the variable into a text file. Search's for the next number, divides it by 2, , and stores the results into a variable like sum2, now adds sum1+sum2 together, then copies the variable into a text file. It does this until it finds 1000. Then the saved variable is added to the 1000 .

PRINT TO DOC = PTD
The world (500/2=250) 250 PTD 250 remains
as we have created it (500/2=250) 250+250 remains .500 PTD 250 remains
is a process (250/2=125) 125+250 remains .375 PTD 125 remains
of our thinking (1000) 1000+125 remains 1.125 PTD 0 remains
It cannot be changed (500 / 2 = 250) 0 remains .250 PTD 250 remains
without changing our thinking .250 remains .250 PTD
1000+250 remains 1.250 PTD
END OF DOC

OUTPUT TO TEXT DOC
1st L-01-TV-01-Clip-01-silence
2nd .250
3rd .500
4th .375
5th 1.125+1-second-fadeout
6th .250
7th 1.250+1-second-fadeout
END OF DOC

Here is what I can contribute

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION


DO UP TO 30 NUMBERS FOUND


for /L %%i in (1,1,30) do (
for /f "tokens=3 delims=. " %%A in (
)
:START

'findstr /rc:"At revision [0-9][0-9]*."'
do echo %%A


IF /I "%%i" EQU "1" GOTO first(


) ELSE (
IF /I "%%A" EQU "250" GOTO small(


) ELSE (
IF /I "%%A" EQU "500" GOTO medium (


) ELSE (
IF /I "%%A" EQU "500" GOTO large (

)

Copy short filename ADD -silence PTD


:first
set /a num1=%%A
set /a sum1=num1/2
set /a remains=sum1
set /a numout1=sum1
echo %numout1% >C:\Labels\L-01\filename-silence.txt
GOTO START


:small
set /a num2=%%A
set /a sum2=num2/2
set /a numout2=sum2+remains
echo %numout2% >C:\Labels\L-01\filename-silence.txt
GOTO START


:medium
set /a num3=%%A
set /a sum3=num3/2
set /a numout3=sum3+remains
echo %numout3% >C:\Labels\L-01\filename-silence.txt
GOTO START


:large
set /a sum4=%%A
set /a numout4=sum4+remains
echo %numout4%+1-second-fadeout >C:\Labels\L-01\filename-silence.txt
GOTO START


ENDLOCAL
ENDLOCAL
)

Open in new window


ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 15 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 15 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004