Simple .bat file help

iParanormalx

The strange one
Messages
1,276
Location
US
Im doing this for a hilariously dumb reason... but I want to have a really easy way to count how many beers I drink on my Twitch stream.

There are a few simple elements i'm trying to take advantage of here:
  • I can use a .txt file as a source on my broadcast
  • I can add a hot-key to a shortcut in windows such as Shift+F9 which will run a shortcut to said .bat file

What I'm thinking is if i have a text file c:\number.txt and the only thing inside of that text document is a 0 then I could have a simple 2-5 line script that would do something like this:

c:\number.txt + 1 output to > c:\number.txt

I want to take the value that is currently inside of number.txt, add 1 to it, and overwrite that new value into number.txt.

The end result is - every time I open a beer, i'll press Shift+F9 and the broadcast will update how many beers I've been drinking.

Problem is syntax for cmd and math is freaking weird... Here are the sources i've been looking at:
I'm no programmer... HALP
 
Last edited:
My problem so far is that every time I try to assign the # in the text file to a variable it just assigns the path of the text file to the variable

Code:
SET "number=C:\number.txt"
echo %number%

It just echoes c:\number.txt

If it would assign the # to the variable then I think all i need is

Code:
SET /a "%number%+1" | > %number%

Does it look like i'm at least along the right path?

Thank you Carnage



edit:
I think i found my key
http://stackoverflow.com/questions/3068929/how-to-read-file-contents-into-a-variable-in-a-batch-file
 
Last edited:
Got it!

Code:
@echo on
set /p number=<C:\number.txt
SET /A newnumber=%number%+1
echo %newnumber% > c:\number.txt

Thank you carnage
 
Back
Top Bottom