JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#526 Post by aGerman » 24 Apr 2022 10:32

I think option /P and friends are helpful here.

Code: Select all

cmd /c jrepl.bat . "" /P "(.+)\r\n(.*)" /PFLAG "" /PREPL "$1+$2" /M /F "a.txt" /O "b.txt"
Steffen

BCX454
Posts: 2
Joined: 01 May 2022 09:50

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#527 Post by BCX454 » 02 May 2022 09:58

It does not work with windows 11 :( It seems like it is discontinued

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#528 Post by aGerman » 02 May 2022 14:55

I'm using JREPL on Win 11 without any problems. If you have issues please elaborate on how to reproduce them.

Steffen

vin97
Posts: 35
Joined: 17 Apr 2020 08:30

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#529 Post by vin97 » 13 Jun 2022 18:35

I ran across a strange problem when running multiple looped batch files in parallel that all execute (individual copies of) JREPL.

Code: Select all

C:\Users\Vini\AppData\Local\Temp\jrepl.bat.14.06.2022_ 2.21.56,50_27286.temp"\\"!")" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
This is a nonsense error that does never ever happen if running only a single batch with exactly the same content.

Which one of the parallel running batch files is the one that fails seems pretty much random, as well as how soon after launch it fails.
The error is much more likely to occur when the batch files are running on low priority and it also correlates with the amount of parallel batch loops.

It seems to me that JREPL needs to generate even finer names for the tempfiles it uses. Maybe even throw in completely random character strings that are unlikely to occur twice.
My explaination is that if two JREPL instances are by chance executed at exactly the same moment, the temp files will overlap and produce strange bugs.
Running on low priority means less executions per second which increases the chance of this happening.

siberia-man
Posts: 208
Joined: 26 Dec 2013 09:28
Contact:

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#530 Post by siberia-man » 14 Jun 2022 03:22

vin97 wrote:
13 Jun 2022 18:35
My explaination is that if two JREPL instances are by chance executed at exactly the same moment, the temp files will overlap and produce strange bugs.
That's true. Once I had the same issue in a pipe which looks like this:

Code: Select all

C:\Temp>type z.bat
@echo:%RANDOM%>&2

C:\Temp>z | z
1826
1826
By the following link you can find the long discussion how we tried to fix it. viewtopic.php?f=3&t=6133&hilit=cmdpid

vin97
Posts: 35
Joined: 17 Apr 2020 08:30

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#531 Post by vin97 » 14 Jun 2022 06:22

siberia-man wrote:
14 Jun 2022 03:22
By the following link you can find the long discussion how we tried to fix it. viewtopic.php?f=3&t=6133&hilit=cmdpid
Before I dive in, did you find a solution or not?
In my case, the total number of maximum parallel JREPL calls is fixed, so in theory I could give each batch file its own JREPL copy and edit this copy to produce tempfiles with an extra prefix.
Do you think this would work?

vin97
Posts: 35
Joined: 17 Apr 2020 08:30

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#532 Post by vin97 » 14 Jun 2022 09:32

Never mind, the solution was on the first page. I just put timeout /t 1 in my cmd.exe spawnloop.

dalewz
Posts: 4
Joined: 07 Jul 2022 09:23

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#533 Post by dalewz » 08 Jul 2022 05:48

Hi Experts,

We are using JREPL.BAT v8.6 to build our installers.

We have a team who add new folders/files under installers folder. every time they did this, we needed to modify the script.
Could Jrepl.bat takes multi input files by using a wild char? here is the script:

call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "Installers\T1\T1Installer_Release.iss" /o -
call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "Installers\M1\M1Installer_Release.iss" /o -

how can i change the above two lines into 1 line?

i tried this:
call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "Installers\*" /o -

it did not work as jrepl reported reading input error. any suggestions?

thanks,
dale

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#534 Post by aGerman » 08 Jul 2022 09:23

You may use a FOR /R loop in order to recursively enumerate all *.iss files in the Installers folder.

Code: Select all

for /r "Installers" %%i in (*.iss) do call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "%%~i" /o -
Steffen

dalewz
Posts: 4
Joined: 07 Jul 2022 09:23

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#535 Post by dalewz » 09 Jul 2022 06:27

Hi Steffen,

Thank you for your help. I tried it but reported input error:
"The filename, directory name, or volume label syntax is incorrect."
buildinstallers-2F-1.PNG
the change is in the left. the original is on the right
buildinstallers-2F-1.PNG (177.82 KiB) Viewed 52664 times
the change is in the left. the original is on the right.

Also, the folder has two iss files: one for release, the other for debug.

test1 for /r "Installers" %%i in (*_Release.iss) do call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "%%~i" /o -
test2 for /r "Installers" %%i in (*.iss) do call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "%%~i" /o -

I tried both test1 and test2. they gave me the same error.

Could you help?
Thank again,
Dale

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#536 Post by aGerman » 09 Jul 2022 08:12

I don't know. Check the contents of your variables. What is the reason for getting output like "Current branch not provided". Also the "ECHO is OFF" is what you'll get if you try to output a variable that is not defined (did not get a value assigned). However, only you can figure out which variable in your script is the culprit ¯\_(ツ)_/¯

Steffen

dalewz
Posts: 4
Joined: 07 Jul 2022 09:23

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#537 Post by dalewz » 09 Jul 2022 14:56

Steffen,

Your change is causing this "The filename, directory name, or volume label syntax is incorrect."

This means we cannot read the input files properly.

Please ignore "Current branch not provided" as i disabled this part of the script.

the main focus is how to read multi files in one line script. i certainly agree with your approach as i thought about the same.
thanks,
dale

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#538 Post by aGerman » 09 Jul 2022 15:25

I created foder "test" on my desktop with subfolder "Installers" (incl. all of what you told before) and test.bat.

test.bat

Code: Select all

@echo off &setlocal
echo ============================================================
tree "%cd%" /f

echo ============================================================
for /r "Installers" %%i in (*.iss) do echo "%%~i"

echo ============================================================
pause
Output:

Code: Select all

============================================================
Auflistung der Ordnerpfade für Volume Windows-SSD
Volumeseriennummer : D470-BFC1
C:\USERS\STEFFEN\DESKTOP\TEST
│   test.bat
│
└───Installers
    ├───M1
    │       M1Installer_Release.iss
    │
    └───T1
            T1Installer_Release.iss

============================================================
"C:\Users\steffen\Desktop\test\Installers\M1\M1Installer_Release.iss"
"C:\Users\steffen\Desktop\test\Installers\T1\T1Installer_Release.iss"
============================================================
Drücken Sie eine beliebige Taste . . .
Of course the *.iss files are just empty text files in my case and it doesn't make sense to call JREPL. However, as the output shows they are found.
Again, I can't help any further because based on the information you gave this test environment is the only thing I was able to create.

Steffen

dalewz
Posts: 4
Joined: 07 Jul 2022 09:23

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#539 Post by dalewz » 12 Jul 2022 12:03

Steffen,

your script works well.

but this in one line does not work:

for /r "..\Installers" %%i in (*_Release.iss) do call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "%%~i" /o -

separately they work well:

for /r "..\Installers" %%i in (*_Release.iss) do echo "%%~i"

call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "Installers\T1\T1Installer_Release.iss" /o -

any suggestions?

thanks,
dale

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#540 Post by aGerman » 12 Jul 2022 13:21

I don't know what you're doing wrong ¯\_(ツ)_/¯
Alright, another attempt ...
I updated my test environment. Having now also a folder "foo" in "test" wherin "test.bat" is saved. Just to show you that the "..\installers" path in the FOR /R loop works as well. Furthermore I update the content of the *.iss files in order to show that JREPL is able to do its job.

test.bat

Code: Select all

@echo off &setlocal
echo ===========================================================================
REM Print the file tree rooted in the parent directory
tree "%cd%\.." /f


REM location of JREPL.bat is the grandparent folder in my case (my desktop)
set jrepl_cmd="..\..\JREPL.bat"
REM I *guess* something about like that is how FINALVERSION is assigned based on what the
REM  search pattern indicates, and based on the fact that you didn't quote %FINALVERSION%
REM  in the command line
set FINALVERSION="4.55.6.7"

REM Find *.iss files
echo ===========================================================================
for /r "..\Installers" %%i in (*_Release.iss) do (
  echo *************************************************************************
  REM See which file is found
  echo found:
  echo "%%~i"
  echo -----------------------------------------------------------------------
  REM For test purposes, write some content into the found file containing a version numbering
  >"%%~i" echo foo version 4.33.222.1 bar baz
  REM Print the current content
  echo content before:
  type "%%~i"
  echo -----------------------------------------------------------------------
  REM For debugging purposes, output the JREPL command line using ECHO,
  REM  deliberately having CALL still the first command because it *may* alter string contents
  call echo %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "%%~i" /o -
  REM Actually call JREPL.bat to replace the version
  call %jrepl_cmd% "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" %FINALVERSION% /f "%%~i" /o -
  echo -----------------------------------------------------------------------
  REM Print the new content
  echo content after:
  type "%%~i"
)

echo ===========================================================================
pause
Output:

Code: Select all

===========================================================================
Auflistung der Ordnerpfade für Volume Windows-SSD
Volumeseriennummer : D470-BFC1
C:\USERS\STEFFEN\DESKTOP\TEST
├───foo
│       test.bat
│
└───Installers
    ├───M1
    │       M1Installer_Release.iss
    │
    └───T1
            T1Installer_Release.iss

===========================================================================
*************************************************************************
found:
"C:\Users\steffen\Desktop\test\Installers\M1\M1Installer_Release.iss"
-----------------------------------------------------------------------
content before:
foo version 4.33.222.1 bar baz
-----------------------------------------------------------------------
"..\..\JREPL.bat" "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" "4.55.6.7" /f "C:\Users\steffen\Desktop\test\Installers\M1\M1Installer_Release.iss" /o -
-----------------------------------------------------------------------
content after:
foo version 4.55.6.7 bar baz
*************************************************************************
found:
"C:\Users\steffen\Desktop\test\Installers\T1\T1Installer_Release.iss"
-----------------------------------------------------------------------
content before:
foo version 4.33.222.1 bar baz
-----------------------------------------------------------------------
"..\..\JREPL.bat" "(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})" "4.55.6.7" /f "C:\Users\steffen\Desktop\test\Installers\T1\T1Installer_Release.iss" /o -
-----------------------------------------------------------------------
content after:
foo version 4.55.6.7 bar baz
===========================================================================
Drücken Sie eine beliebige Taste . . .
Read the comments in the script and see what I did for debugging reasons. Just try to do something similar in your script. Also you may want to turn ECHO ON at the beginning of your script in order to see which command lines do actually cause errors.

Steffen

Post Reply