Batch File: Integers in a Txt File Variable

August 28, 2009 at 07:34:51
Specs: Windows Vista Home P, Core 2 Quad 8200/6gb
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)


See More: Batch File: Integers in a Txt File Variable

Report •


#1
August 28, 2009 at 08:00:22
Do you want them in separate vars?


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
August 28, 2009 at 08:04:17
Yes, I need them in separate variables.

Report •

#3
August 28, 2009 at 08:39:27
@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


Report •

Related Solutions

#4
August 28, 2009 at 12:42:04
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


Report •

#5
August 28, 2009 at 13:16:49
Why not use VBScript, or some other (better) scripting language?

Report •


Ask Question