For brc64.exe, the /RegExp: will forbid more than 9-groups, and also any groups like (?:), so it needs to be a
very long command like...
- Code: Select all
"C:\Path\To\Your\brc64.exe" /Dir:"C:\Path\To\MainFolder" /Pattern:*•* /Recursive /NoFolders /ReplaceCI:•:"|" /RegExp:"(.+) (\|(\d{0,2}[-_])?(Jan|January|Feb|February|Mar|March|Apr|April|May|June?|July?|Aug|August|Oct|October|Sept|September|Nov|November|Dec|December)([-_](Jan|January|Feb|February|Mar|March|Apr|April|May|June?|July?|Aug|August|Oct|October|Sept|September|Nov|November|Dec|December))?([-_]\d{0,2})?[-_](19|20)\d\d)(.*):\2 \1\9" /RegExp:"^(\|)(\d)([-_])([^-_]+)(.*):\1\4\30\2\5" /RegExp:"^(\|)(\d\d)([-_])([^-_]+)(.*):\1\4\3\2\5" /Regexp:"^(\|[^-_]+[-_])(\d[-_].*):\10\2" /RegExp:"^(\|[a-zA-Z]+)[-_][^\d]+([-_].*):\1\2" /RegExp:"^(\|)Jan(uary)?[-_](.*):\101\3" /RegExp:"^(\|)Feb(ruary)?[-_](.*):\102\3" /RegExp:"^(\|)Mar(ch)?[-_](.*):\103\3" /RegExp:"^(\|)Apr(il)?[-_](.*):\104\3" /RegExp:"^(\|)May[-_](.*):\105\3" /RegExp:"^(\|)June?[-_](.*):\106\3" /RegExp:"^(\|)July?[-_](.*):\107\3" /RegExp:"^(\|)Aug(ust)?[-_](.*):\108\3" /RegExp:"^(\|)Sept(ember)?[-_](.*):\109\3" /RegExp:"^(\|)Oct(ober)?[-_](.*):\110\3" /RegExp:"^(\|)Nov(ember)?[-_](.*):\111\3" /RegExp:"^(\|)Dec(ember)?[-_](.*):\112\3" /RegExp:"(^\|\d{4})[-_](\d{4}.*):\1\2" /RegExp:"(^\|)(\d{2,4})(\d{4})(.*):\1\3\2\4" /Regexp:"^\|(.+):\1" /ReplaceCI:"|:•"
If adding /Execute to the end, it renames like...
Title1 •
September_2022.txt ----------------> 2022
09 Title1.txt
Title2 •
September-October_2022.txt ------> 2022
09 Title2.txt
Title3 •
Sept-Oct_2022.jpg ------------------> 2022
09 Title3.jpg
Title4 •
September_
1_2022.txt -------------> 2022
0901 Title4.txt
Title5 •
25_
November_2022.txt ------------> 2022
1125 Title5.txt
Title6 •
4_
October_2022.txt ----------------> 2022
1004 Title6.txt
Title7 •
8_
September_2022 •Issue1.txt ---> 2022
0908 Title7 •Issue1.txt
Title8 •Issue_15.txt -------------------------> (no changes, because no •date)
Title9 • more_text •Issue_15.txt ----------> (no changes, because no •date)
But would 1st need to edit both
/Dir: and
/Pattern: and also the path at the very beginning, to conduct properly.
If not all of the month-words are getting matched, could just add some more different spellings to be matched.
Or if needing any help to modify, can just say some example-abbreviations or spellings for the month-words.
The command is a little longer than it needs to be, just because Im making it an easier command to experiment with.
The /RegExp: wont like
any bullet-characters, so they must be converted into '|', before /RegExp: will conduct normally.
The rest just matches your different conditions, replaces month-words with numbers, and move them like the examples.
If your names have any other extended-ASCII chars, they would also need to be replaced like above, before using the /RegExp:.
So this is actually
much easier to conduct with either the javascript or bru, because not having all these limitations.
If the preview on the command-line looks correct, you could add
/Execute to the very end, to conduct any renames.
If needing help to modify anything, or explanations about the different /RegExp:, can always post back again.
If the command already has /Execute and its ready to put in a batch, the batch first needs a line like...
chcp 1252This to let the
batch properly conduct extended-ASCII chars, just like the command-line conducts them.
Its unfortunate, but modern text-editors dont grant Encoding==Extended-ASCII when inventing batch-files?
========================== Javascript ==========================================
For javascript, it can be more like...
- Code: Select all
step1=name.replace(/(.+) •((\d{0,2}[-_])?(Jan|January|Feb|February|Mar|March|Apr|April|May|June?|July?|Aug|August|Oct|October|((Sept|Nov|Dec)(ember)?))([-_](Jan|January|Feb|February|Mar|March|Apr|April|May|June?|July?|Aug|August|Oct|October|Sept|September|Nov|November|Dec|December))?([-_]\d{0,2})?[-_](19|20)\d\d)/, ':$2 $1')
step2=step1.replace(/(:)(\d)([-_])([^-_]+)/, '$1$4$30$2')
step3=step2.replace(/(:)(\d\d)([-_])([^-_]+)/, '$1$4$3$2')
step4=step3.replace(/(:[^-_]+[-_])(\d[-_])/, '$10$2')
step5=step4.replace(/(:[a-zA-Z]+)[-_][^\d]+([-_])/, '$1$2')
jan=step5.replace(/(:)Jan(uary)?[-_]/, '$1'+'01'); feb=jan.replace(/(:)Feb(ruary)?[-_]/, '$1'+'02')
mar=feb.replace(/(:)Mar(ch)?[-_]/, '$1'+'03'); apr=mar.replace(/(:)Apr(il)?[-_]/, '$1'+'04')
may=apr.replace(/(:)May[-_]/, '$1'+'05'); jun=may.replace(/(:)June?[-_]/, '$1'+'06')
jul=jun.replace(/(:)July?[-_]/, '$1'+'07'); aug=jul.replace(/(:)Aug(ust)?[-_]/, '$1'+'08')
sep=aug.replace(/(:)Sept(ember)?[-_]/, '$1'+'09'); oct=sep.replace(/(:)Oct(ober)?[-_]/, '$1'+'10')
nov=oct.replace(/(:)Nov(ember)?[-_]/, '$1'+'11'); dec=nov.replace(/(:)Dec(ember)?[-_]/, '$1'+'12')
noseps=dec.replace(/(:\d{4})[-_](\d{4})/, '$1$2')
newName=noseps.replace(/:(\d{2,4})(\d{4})/, '$2$1')
Or can also add comments like...
- Code: Select all
// Match all possible •date-formats, and mark these names with : at the beginning...
step1=name.replace(/(.+) •((\d{0,2}[-_])?(Jan|January|Feb|February|Mar|March|Apr|April|May|June?|July?|Aug|August|Oct|October|((Sept|Nov|Dec)(ember)?))([-_](Jan|January|Feb|February|Mar|March|Apr|April|May|June?|July?|Aug|August|Oct|October|Sept|September|Nov|November|Dec|December))?([-_]\d{0,2})?[-_](19|20)\d\d)/, ':$2 $1')
// Now its easier searching for : instead of typing the very long •date-formats again!
// Pad and move 1-digit before month-words...
step2=step1.replace(/(:)(\d)([-_])([^-_]+)/, '$1$4$30$2')
// Convert dd_MonthWord --> MonthWord-dd...
step3=step2.replace(/(:)(\d\d)([-_])([^-_]+)/, '$1$4$3$2')
// Pad 1-digit after month-words...
step4=step3.replace(/(:[^-_]+[-_])(\d[-_])/, '$10$2')
// Destroy 2nd-month in MonthText-MonthText ranges...
step5=step4.replace(/(:[a-zA-Z]+)[-_][^\d]+([-_])/, '$1$2')
// Convert month-text into mm...
jan=step5.replace(/(:)Jan(uary)?[-_]/, '$1'+'01'); feb=jan.replace(/(:)Feb(ruary)?[-_]/, '$1'+'02')
mar=feb.replace(/(:)Mar(ch)?[-_]/, '$1'+'03'); apr=mar.replace(/(:)Apr(il)?[-_]/, '$1'+'04')
may=apr.replace(/(:)May[-_]/, '$1'+'05'); jun=may.replace(/(:)June?[-_]/, '$1'+'06')
jul=jun.replace(/(:)July?[-_]/, '$1'+'07'); aug=jul.replace(/(:)Aug(ust)?[-_]/, '$1'+'08')
sep=aug.replace(/(:)Sept(ember)?[-_]/, '$1'+'09'); oct=sep.replace(/(:)Oct(ober)?[-_]/, '$1'+'10')
nov=oct.replace(/(:)Nov(ember)?[-_]/, '$1'+'11'); dec=nov.replace(/(:)Dec(ember)?[-_]/, '$1'+'12')
// Remove dd_yyyy separators...
noseps=dec.replace(/(:\d{4})[-_](\d{4})/, '$1$2')
// Move yyyy to front and destroy : ...
newName=noseps.replace(/:(\d{2,4})(\d{4})/, '$2$1')
========================== BRU with RegEx(1) ==========================================
For users without a commercial license, or not like using the command-line, there is still another way.
The RegEx(1) can use a checkmark inside for "v2", but then its a
very long "Match" like...
- Code: Select all
(.+) •((\d{0,2}[-_])?(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|June?|July?|Aug|August|Oct|October|((Sept|Nov|Dec)(ember)?))([-_](Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|June?|July?|Aug|August|Oct|October|((Sept|Nov|Dec)(ember)?)))?([-_]\d{0,2})?[-_](19|20)\d\d)(?X)(:)(\d)([-_])([^-_]+)(?X)(:)(\d\d)([-_])([^-_]+)(?X)(:[^-_]+[-_])(\d[-_])(?X)(:[a-zA-Z]+)[-_][^\d]+([-_])(?X)(:)Jan(uary)?[-_](?X)(:)Feb(ruary)?[-_](?X)(:)Mar(ch)?[-_](?X)(:)Apr(il)?[-_](?X)(:)May[-_](?X)(:)June?[-_](?X)(:)July?[-_](?X)(:)Aug(ust)?[-_](?X)(:)Sept(ember)?[-_](?X)(:)Oct(ober)?[-_](?X)(:)Nov(ember)?[-_](?X)(:)Dec(ember)?[-_](?X)(:\d{4})[-_](\d{4})(?X):(\d{2,4})(\d{4})
And a "Replace" like...
- Code: Select all
:$2 $1(?X)$1$4${3}0$2(?X)$1$4$3$2(?X)${1}0$2(?X)$1$2(?X)${1}01(?X)${1}02(?X)${1}03(?X)${1}04(?X)${1}05(?X)${1}06(?X)${1}07(?X)${1}08(?X)${1}09(?X)${1}10(?X)${1}11(?X)${1}12(?X)$1$2(?X)$2$1
Like therube is saying, any javascript methods for this solution might also help others to learn.
Glad you found a solution?