TEXT REPLACE BATCH FILE

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

TEXT REPLACE BATCH FILE

#1 Post by coolhandpuke » 13 Dec 2014 10:36

Hi guys,

I have been trying for hours and I am very close but there is something I am doing wrong.....

Here is what I am trying to acheive

I have pokertracker 4, which for those not knowing is a hand and stst tracker for online poker, it reads the hand histories from various online poker sites and you can review hand histories and use a HUD for targeting weakplayers etc. Now the histories are stored by each site in a specific place in a .TXT format

The site I am currently using is not supported by pokertracker but I have found that I can edit the txt file just by changing the name of the poker room in the txt file, there are other issues with the file but I am nbot bothered about those stats being incorrect.

I Have so far tried xcopy and robocopy in batch files and havce set it with a loop and timer so it can pull hands live from the file, the problem I am getting is that while I am playing the txt document is being constantly updated by the poker client and I need to copy this file ever 10 seconds for example and move it to another location on my hard drive, I can then direct pokertracker to the new folder where the files are copied to and have the batch file change the name of the poker room within the txt file

I hope I am making sense and you are all following me....

So far my only succes has been to have the job complete one and keeps looping but doesnt seem to update the files it skips them, hope you can help

here is the batch file thus far

Code: Select all

:loop
XCOPY "C:\Users\Better than peter\AppData\Roaming\YachtingPoker\HandHistoryNG\JasonWells" E:\yachtinghistory
timeout /T 10
"C:\Users\Better than peter\Desktop\Find&Replace.exe" --cl --dir "E:\yachtinghistory" --fileMask "*.*" --excludeFileMask "*.dll, *.exe" --includeSubDirectories --find "Hive Poker" --replace "PokerStars"
timeout /T 10
goto loop


Thanks in advance

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: TEXT REPLACE BATCH FILE

#2 Post by foxidrive » 14 Dec 2014 00:45

You are copying a file, editing it, and looping back to do it again.

You have two delays of 10 seconds.

How is it failing?

There are other ways to edit a file and do this, if you specify where the file is, the name it has to be before and after, and where the file has to go,
plus the text that needs to be changed.

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

Re: TEXT REPLACE BATCH FILE

#3 Post by coolhandpuke » 14 Dec 2014 04:46

thanks for the reply, Ok so to help you understand, while I am playing poker the poker client is editing the.txt after every hand, I cannot edit that file on the fly as I receive an error that the txt is in use by another price I.e. the client. So to workaround this instead I am wanting to copy the original txt every 10 seconds and move it to the second location and overwrite, then in the copied location the second part of the batch file changers the name.

It works once but then skips the original files and does nothing

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: TEXT REPLACE BATCH FILE

#4 Post by foxidrive » 14 Dec 2014 09:22

This will copy file.txt then go to the folder, edit the file.txt and do it every 10 seconds.

Code: Select all

@echo off
:loop
COPY "C:\Users\Better than peter\AppData\Roaming\YachtingPoker\HandHistoryNG\JasonWells\file.txt" "E:\yachtinghistory" >nul
pushd "E:\yachtinghistory"
    call "%~dp0\jrepl.bat"  "Hive Poker" "PokerStars" /L /F "file.txt" /O -
popd
timeout /T 10 /nobreak >nul
goto :loop


This uses a helper batch file called `Jrepl.bat` (by dbenham) - download from: https://www.dropbox.com/s/4otci4d4s8x5ni4/Jrepl.bat

Place `Jrepl.bat` in the same folder as the batch file

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

Re: TEXT REPLACE BATCH FILE

#5 Post by coolhandpuke » 14 Dec 2014 11:43

I'm afraind this doesnt seem to do anything, opens cmd windows and closes, no files in the location folder only sub folders which are correct, folders are date for example, 2014-12 for dec 2014 and inside there will be the .txt files that I have played, 1 for each tournament played that day!

the source folder has todays files but there is nothing transfered using your batch and that addon, both placed inside a folder on desktop

Thanks for trying to help

Squashman
Expert
Posts: 4483
Joined: 23 Dec 2011 13:59

Re: TEXT REPLACE BATCH FILE

#6 Post by Squashman » 14 Dec 2014 16:56

Put a CALL at the beginning of this line.

Code: Select all

CALL "%~dp0\jrepl.bat"  "Hive Poker" "PokerStars" /L /F "file.txt" /O -

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: TEXT REPLACE BATCH FILE

#7 Post by foxidrive » 14 Dec 2014 18:39

Squashman wrote:Put a CALL at the beginning of this line.

Code: Select all

CALL "%~dp0\jrepl.bat"  "Hive Poker" "PokerStars" /L /F "file.txt" /O -



Good catch Squashman. Ta.

I edited the post above.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: TEXT REPLACE BATCH FILE

#8 Post by foxidrive » 14 Dec 2014 18:41

coolhandpuke wrote:the source folder has todays files but there is nothing transfered using your batch and that addon, both placed inside a folder on desktop


One thing you haven't been clear about is the filename that needs to be edited. Are you saying that there are a bunch of files that need to be edited?

You've need to describe the names and locations, as I used a generic filename file.txt as an example.

Squashman
Expert
Posts: 4483
Joined: 23 Dec 2011 13:59

Re: TEXT REPLACE BATCH FILE

#9 Post by Squashman » 14 Dec 2014 19:06

Looks like he was changing all files in a directory.
Looking at the third party utility he was using.

Code: Select all

--fileMask "*.*"

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: TEXT REPLACE BATCH FILE

#10 Post by foxidrive » 14 Dec 2014 19:12

Squashman wrote:Looks like he was changing all files in a directory.
Looking at the third party utility he was using.

Code: Select all

--fileMask "*.*"


Yes, and it's hard to say what is being edited because the exclude mask is using *.dll and *.exe as if an entire program folder is being copied.

It's possible that it's just one .INI file that is being edited...

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

Re: TEXT REPLACE BATCH FILE

#11 Post by coolhandpuke » 15 Dec 2014 03:34

Sorry for the confusion,

Ok the source folder is the folder I have put, inside this folder there will be folders created every month, inside these folders are .txt files for all the various games I have played within that month, these.txt files inside the monthly folders need to either be changed on the fly (poker client is using process, hence copying first) or all the folders and contents inside source folder should be copied over to the destination and edited, and then go in to a loop and do it again hence catching new hands played during live play?

Doors this make sense?

Thanks for all your help

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: TEXT REPLACE BATCH FILE

#12 Post by foxidrive » 15 Dec 2014 03:38

coolhandpuke wrote:Ok the source folder is the folder I have put, inside this folder there will be folders created every month, inside these folders are .txt files for all the various games I have played within that month, these.txt files inside the monthly folders need to either be changed on the fly (poker client is using process, hence copying first) or all the folders and contents inside source folder should be copied over to the destination and edited, and then go in to a loop and do it again hence catching new hands played during live play?

Doors this make sense?


Something we don't yet know is what is happening to the files after they are edited.

1) Where do they go?
2) Are they copied back to where they came from and overwriting the original files??
3) If the original files are locked, and in use, then what do you do with the edited copies?

Your original xcopy command isn't copying sub-directories at all either.

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

Re: TEXT REPLACE BATCH FILE

#13 Post by coolhandpuke » 15 Dec 2014 10:34

Ok so the original txt files are locked in the poker client hand history folder, what I am trying to do is effectively copy all sub folders including files (.txt) to my destination folder so as I can then let the batch file replace the HIVE POKER with POKERSTARS (when locked cannot be read or edited hence the destination for copying), one all files have been copied over to destination they can then be edited with the batch file command to change the poker room name. these files can then be read and used to update the hand tracker on the fly.

I have not been very clear have I, but thanks so much for trying to help a noob

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: TEXT REPLACE BATCH FILE

#14 Post by foxidrive » 15 Dec 2014 14:36

coolhandpuke wrote:I have not been very clear have I, but thanks so much for trying to help a noob


We are happy to help, that's the aim of DosTips, but the task needs a little more description.

Say you have this:

c:\poker\apple\hand1.txt
c:\poker\banana\hand2.txt
c:\poker\grape\hand3.txt

and you want to copy them here

E:\yachtinghistory\apple\hand1.txt
E:\yachtinghistory\banana\hand2.txt
E:\yachtinghistory\grape\hand3.txt


and edit them all, that is easy.

Is that all you need help doing?

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

Re: TEXT REPLACE BATCH FILE

#15 Post by coolhandpuke » 15 Dec 2014 16:22

C:pokeroom/handhistory/date file

Inside these date files are each of the months various tournament text files

names.txt

I want to copy the date files completely including the text files inside to

D:handhistory

Then I want to scan and replace hive poker (text inside the.txt) to pokerstars

Then I need to loop and do it again because on average there will be a new hand every 30 seconds or so and the data in the names.txt well have changed because of the new hand, so copy, overwrite existing from previous run, rinse and repeat

Following me ok?

Post Reply