I am using Total Commander file rename utility, and the file names contain dates, for example
May/04/2021
I want to normalize dates and make them sortable by formatting them as YYYY-MM-DD
, so have the following regular expression:
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\/(\d\d?)\/((\d\d)?(\d\d))
#\1 \2 \3 \4 \5 \6 \7 \8 \9 \10 \11 \12 <--- index of matched capture group text
# possible alternative regex:
((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))\/(\d\d?)\/((\d\d)?(\d\d))
In the replacement string, instead of using the actual captured text in the group (in this case, May
) I want to replace it with the index number of the captured text within the group, which in this case would be 5
, such that the final result would be:
2021-05-04
00
instead of just 0
?(I suspect a script may be the only way to do this, but if there is some special regular expression syntax I am unaware of I'd like to find out).