TEXT REPLACE BATCH FILE

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: TEXT REPLACE BATCH FILE

#16 Post by dbenham » 16 Dec 2014 22:48

It doesn't make much sense to reprocess the entire file each time interval. Wouldn't it be better to only append the new lines (after modifying)?

The following should work provided
- none of the lines are longer than 1021 bytes,
- you don't need to preserve empty lines
- you don't have control characters at the end of lines that need to be preserved

Your poker tracker software can monitor the modified output in nearly real time :)

EDIT: Added the critical stdout redirection to the output file. I originally removed it for testing, and forgot to put it back
EDIT: Path to input file now expected in %1 and path to output directory in %2

fixHivePoker.bat

Code: Select all

@echo off
setlocal enableDelayedExpansion
set "in=%~1"
set "out=%~f2.\%~nx1"

call :processInput <"%in%" >"%out%"
exit /b

:processInput
set "ln="

:: My choice of 100 is somewhat arbitrary
:: I'm assuming the input never has 100 consecutive empty lines
:: If there are never empty lines, then you can remove the FOR /L loop entirely
:: and just keep the inner portion
for /l %%N in (1 1 100) do (
  set /p "ln="
  if defined ln (
    %= Make whatever changes you need here =%
    set "ln=!ln:Hive Poker=PokerStars!"
    %= Write the line to the output =%
    echo(!ln!
    goto :processInput
  )
)

:: If input is no longer locked, then we are done
2>nul (call >>"%in%" && exit /b)

:: Can't use TIMEOUT when input has been redirected so use PING delay instead
:: If your machine has more than one CPU or multiple cores, then this delay may not be needed
ping localhost /n 2 >nul

goto :processInput


Dave Benham
Last edited by dbenham on 21 Dec 2014 15:25, edited 1 time in total.

coolhandpuke
Posts: 8
Joined: 13 Dec 2014 10:26

Re: TEXT REPLACE BATCH FILE

#17 Post by coolhandpuke » 21 Dec 2014 13:36

Hi Dave and thanks I dont understand what I need to edit in your batch file, anyway here is some more information i thought I would try and make it more understandable.

here is an example of the DATA contained in the .txt files. As we already know I need to change Hive Poker to Pokerstars in order for POKERTRACKER to be able to read them. The file name of each .txt file inside the folder is whatever the name of the tournament is, in this case "2014-12-20-#1293827-HPF 17 €5,000 GTD R + A.txt"

Code: Select all

Hive Poker Game #239437007: Tournament #1293827, Table #14, €10+€1 EUR Hold'em No Limit - Level 1 (10/20) - 2014/12/20 - 20:00:02 (UTC)
Table 'HPF 17 €5,000 GTD R + A' 8-max Seat #2 is the button
Seat 1: AAAAQQQQ (3000 in chips) is sitting out
Seat 2: BLIKE_05 (7000 in chips)
Seat 3: 666TheBeast (7000 in chips)
Seat 4: attack4cash (3000 in chips)
Seat 5: c@llfor3v3r (7000 in chips)
Seat 6: Bob (7000 in chips)
Seat 7: jon64 (3000 in chips)
Seat 8: DontB3Sadm8 (7000 in chips)
666TheBeast: posts small blind 10
attack4cash: posts big blind 20
*** HOLE CARDS ***
Dealt to Bob [9s 2h]
c@llfor3v3r: folds
Bob: folds
jon64: calls 20
DontB3Sadm8: folds
AAAAQQQQ: calls 20
BLIKE_05: folds
666TheBeast: calls 10
attack4cash: checks
*** FLOP *** [Th 7d 7h]
666TheBeast: checks
attack4cash: checks
jon64: checks
AAAAQQQQ: checks
*** TURN *** [Th 7d 7h] [6s]
666TheBeast: bets 53
attack4cash: raises 186 to 239
jon64: folds
AAAAQQQQ: folds
666TheBeast: folds
Uncalled bet (186) returned to attack4cash
attack4cash: doesn't show hand
attack4cash collected 186 from pot
*** SUMMARY ***
Total pot 186 | Rake 0
Board [Th 7d 7h 6s]
Seat 1: AAAAQQQQ folded on the Turn
Seat 2: BLIKE_05 folded before Flop
Seat 3: 666TheBeast (small blind) folded on the Turn
Seat 4: attack4cash (big blind) collected (186)
Seat 5: c@llfor3v3r folded before Flop
Seat 6: Bob folded before Flop
Seat 7: jon64 folded on the Turn
Seat 8: DontB3Sadm8 folded before Flop



Hive Poker Game #239438473: Tournament #1293827, Table #14, €10+€1 EUR Hold'em No Limit - Level 1 (10/20) - 2014/12/20 - 20:02:05 (UTC)
Table 'HPF 17 €5,000 GTD R + A' 8-max Seat #3 is the button
Seat 1: AAAAQQQQ (2980 in chips) is sitting out
Seat 2: BLIKE_05 (7000 in chips)
Seat 3: 666TheBeast (6927 in chips)
Seat 4: attack4cash (3113 in chips)
Seat 5: c@llfor3v3r (7000 in chips)
Seat 6: Bob (7000 in chips)
Seat 7: jon64 (2980 in chips)
Seat 8: DontB3Sadm8 (7000 in chips)
attack4cash: posts small blind 10
c@llfor3v3r: posts big blind 20
*** HOLE CARDS ***
Dealt to Bob [6c 9s]
Bob: folds
jon64: calls 20
DontB3Sadm8: folds
AAAAQQQQ: folds
BLIKE_05: folds
666TheBeast: folds
attack4cash: folds
c@llfor3v3r: checks
*** FLOP *** [Ah Tc Td]
c@llfor3v3r: checks
jon64: checks
*** TURN *** [Ah Tc Td] [Th]
c@llfor3v3r: bets 33
AAAAQQQQ has returned
jon64: calls 33
*** RIVER *** [Ah Tc Td Th] [Kh]
c@llfor3v3r: bets 116
jon64: calls 116
*** SHOW DOWN ***
c@llfor3v3r: shows [Qh 7d] (Three of a kind, Tens)
jon64: shows [Kc 3c] (Full House, Tens full of Kings)
jon64 collected 348 from pot
*** SUMMARY ***
Total pot 348 | Rake 0
Board [Ah Tc Td Th Kh]
Seat 1: AAAAQQQQ folded before Flop
Seat 2: BLIKE_05 folded before Flop
Seat 3: 666TheBeast folded before Flop
Seat 4: attack4cash (small blind) folded before Flop
Seat 5: c@llfor3v3r (big blind) showed [Qh 7d] and lost with Three of a kind, Tens
Seat 6: Bob folded before Flop
Seat 7: jon64 showed [Kc 3c] and won (348) with Full House, Tens full of Kings
Seat 8: DontB3Sadm8 folded before Flop


these .txt files are by default located here C:\Users\Better than peter\AppData\Roaming\YachtingPoker\HandHistoryNG\Bob\2014-12

these files cannot be opened when the poker client is running as they are locked by the client!

To get around this I want to copy the subfolder C:\Users\Better than peter\AppData\Roaming\YachtingPoker\HandHistoryNG\Bob including all folders and subfiles

to

E:\yachtinghistory

Then I need the copy replace command to change Hive Poker to Pokerstars

set up a loop and then hopefully it continues to update all the new data as I play???

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: TEXT REPLACE BATCH FILE

#18 Post by dbenham » 21 Dec 2014 15:39

I've modified my script in my prior post to make it easier to use. Please try it.

I've called the script fixHivePoker.bat, so if the game in your example were actively running, you would run the following commands in a dedicated command session:

Code: Select all

pushd "C:\Users\Better than peter\AppData\Roaming\YachtingPoker\HandHistoryNG\Bob\2014-12"
md "E:\yachtinghistory\Bob\2014-12" 2>nul
fixHivePoker  "2014-12-20-#1293827-HPF 17 €5,000 GTD R + A.txt"  "E:\yachtinghistory\Bob\2014-12"

You won't see anything on the screen, but the script will run continuously as long as the game continues, copying the modified information for that one game to your desired location in real time.

You should be able to run your POKERTRACKER against the modified copy in real time.


Dave Benham

coolhandpuke
Posts: 8
Joined: 13 Dec 2014 10:26

Re: TEXT REPLACE BATCH FILE

#19 Post by coolhandpuke » 21 Dec 2014 16:55

Ok so this will control the moving of the files?

Is this supposed to go inside the above code?

Sorry like I said I'm a total newbie, can't see anything in the last code that changed the text to pokerstars?

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: TEXT REPLACE BATCH FILE

#20 Post by dbenham » 21 Dec 2014 17:13

Please read my prior two posts more carefully. The script that actually copies the modified data to the new location is from two posts ago. The code that makes the change is in the middle.

My last post simply shows how you would call the script.

Post Reply