Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a batch file that will grab the specific numbers from a text file and put them into a variable. The numbers are frames from an AviSynth script.
My avisynth script looks something like this:
AviSource("Input.avi")
a = Trim(2790,19924)
b = Trim(26851,50246)
a ++ b
So what I would like to do is take each of the frame numbers(2790,19924, 26851, and 50246) and put them into a separate variable that I can call somewhere else, but I don't have clue how to do it.
(btw the subject was supposed to be "Batch File: Integers in a Txt File > Variable" but I guess it removed the arrow)

Do you want them in separate vars?
=====================================
If at first you don't succeed, you're about average.M2

@echo off & setLocal EnableDELAYedExpansion
for /f "tokens=* delims= " %%a in ('find "=" ^< myfile') do (
for /f "tokens=1,3-4 delims==,() " %%i in ("%%a") do (
set %%i1=%%j & set %%i2=%%k
)
)
set
=====================================
If at first you don't succeed, you're about average.M2

Thanks, worked perfectly. I, however, didn't realize that you couldn't perform arithmetic operations with floating point numbers in batch files, so I had to get a command line calculator to do it instead, making this a lot more complex then I thought it was going to be. Here is what I ended up with:
@echo off & setLocal EnableDELAYedExpansion
for /f "tokens=* delims= " %%a in ('find "=" ^< 1.avs') do (
for /f "tokens=1,3-4 delims==,() " %%i in ("%%a") do (
set %%i1=%%j & set %%i2=%%k
)
)
set"C:\Program Files (x86)\commandlinecalc\calc" %a1%/(30000/1001)>temp.txt
set a1=
for /f "delims=" %%a in (temp.txt) do (
set currentline=%%a
set a1=!a1!!currentline!
)del temp.txt
"C:\Program Files (x86)\commandlinecalc\calc" %a2%/(30000/1001)>temp.txt
set a2=
for /f "delims=" %%a in (temp.txt) do (
set currentline=%%a
set a2=!a2!!currentline!
)del temp.txt
"C:\Program Files (x86)\commandlinecalc\calc" %b1%/(30000/1001)>temp.txt
set b1=
for /f "delims=" %%a in (temp.txt) do (
set currentline=%%a
set b1=!b1!!currentline!
)del temp.txt
"C:\Program Files (x86)\commandlinecalc\calc" %b2%/(30000/1001)>temp.txt
set b2=
for /f "delims=" %%a in (temp.txt) do (
set currentline=%%a
set b2=!b2!!currentline!
)del temp.txt

![]() |
Compare source filesize a...
|
Loop That Stores User Inp...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |