by trm2 » Wed Feb 05, 2020 7:07 pm
I like your idea, since Brc can run multiple RegEx in a single run it can handle much more than the 3 or 4 names I was struggling with.
Unfamiliar as I am though with BRC at the moment, I have a problem running it:
It comes up with an error 3 when looking at the log - 'can't find specified path'. I have recreated your samples and placed them in a directory h:\A Test Folder.
It changes to the directory so that path is correct.
The files - all of the samples give reside in the single directory - but of course the program as far as I can tell never gets that far. Besides if it was a
matter of a missing file it would return an error code 2.
Samples:
CAN - FirstLast.docx
CAN-First Last.docx
CAN-FirstLast.docx
UK-JoLii1-JoLii2-JoLii3-JoLii4-JoLii5-JoLii6
Here is the code:
rem @echo off
cd "h:\A Test folder"
set reg1=/Regexp:"^([A-Z]{2,})-([A-Z][^A-Z -]*?)([A-Z].*)$:\1|\2 \3"
set reg2=/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
set max10=%reg2% %reg2% %reg2% %reg2% %reg2% %reg2% %reg2% %reg2% %reg2%
set reg3=/Regexp:"(.*[|].*), (.*):\1 and \2"
set reg4=/Regexp:"(.*)[|](.*):\1 - \2"
H:\BRC_Unicode_64\brc64.exe /Pattern:*-*.docx %reg1% %max10% %reg3% %reg4%
pause>nul
EXIT /B %ERRORLEVEL%
I need the preview results so I left off /EXECUTE and added the return code
My understanding of the batch is as follows:
1. set Assign a Regex to each environmental variable identified as: reg1, reg2, max10, reg3 and reg4
2. brc32 Executes the Brc program
3. /Pattern: *.*.docx Process all Word docx files found in directory
4. % Execute all RegEx in order specified
When run:
Processing Folder h:\A Test Folder\
This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
h:\A Test Folder>pausel>nul
Log:
--------------------------------------------------------------------------------------------------------
H:\BRC_Unicode_64>rem @echo off
H:\BRC_Unicode_64>cd "h:\A Test folder"
h:\A Test Folder>set reg1=/Regexp:"^([A-Z]{2,})-([A-Z][^A-Z -]*?)([A-Z].*)$:\1|\2 \3"
h:\A Test Folder>set reg2=/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
h:\A Test Folder>set max10=
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
h:\A Test Folder>set reg3=/Regexp:"(.*[|].*), (.*):\1 and \2"
h:\A Test Folder>set reg4=/Regexp:"(.*)[|](.*):\1 - \2"
h:\A Test Folder>H:\BRC_Unicode_64\brc64.exe /Pattern:*-*.docx
/Regexp:"^([A-Z]{2,})-([A-Z][^A-Z -]*?)([A-Z].*)$:\1|\2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"^(.*[|][^-]*)-([A-Z][^A-Z -]*?)([A-Z].*)$:\1, \2 \3"
/Regexp:"(.*[|].*), (.*):\1 and \2" /Regexp:"(.*)[|](.*):\1 - \2"
h:\A Test Folder>pause1>nul
h:\A Test Folder>EXIT /B 3
-------------------------------------------------------------------------------------------
Further questions -
1. Your last sample, beginning with UK with no extension, perhaps this is overlooked - should be docx, otherwise it won't get processed because your
pattern specifies *.docx files only?
2. What happens without the /EXECUTE parameter - I mean how does it display the rename preview unless it brings up the GUI version momentarily?
bru, please assist.
Thanks in advance.