Computing.Net > Forums > Programming > Batch File: Integers in a Txt File Variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File: Integers in a Txt File Variable

Reply to Message Icon

Name: blazerqb14
Date: August 28, 2009 at 07:34:51 Pacific
OS: Windows Vista Home P
CPU/Ram: Core 2 Quad 8200/6gb
Subcategory: Batch
Comment:

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)



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 28, 2009 at 08:00:22 Pacific
Reply:

Do you want them in separate vars?


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

M2


0

Response Number 2
Name: blazerqb14
Date: August 28, 2009 at 08:04:17 Pacific
Reply:

Yes, I need them in separate variables.


0

Response Number 3
Name: Mechanix2Go
Date: August 28, 2009 at 08:39:27 Pacific
Reply:

@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


0

Response Number 4
Name: blazerqb14
Date: August 28, 2009 at 12:42:04 Pacific
Reply:

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


0

Response Number 5
Name: Razor2.3
Date: August 28, 2009 at 13:16:49 Pacific
Reply:

Why not use VBScript, or some other (better) scripting language?


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Compare source filesize a... Loop That Stores User Inp...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File: Integers in a Txt File Variable

How to delete first for lines in a txt file www.computing.net/answers/programming/how-to-delete-first-for-lines-in-a-txt-file/20172.html

Simple question Batch file help www.computing.net/answers/programming/simple-question-batch-file-help/15400.html

script that searches lines in a txt www.computing.net/answers/programming/script-that-searches-lines-in-a-txt/16283.html