Page 1 of 1

Convert Months into numbers?

PostPosted: Sun Aug 08, 2021 4:47 am
by amazing
Image
Taking this as example, How do I rename them in numbers, and only take the shortened version of the year instead of 4 digits?
E.g.
21-04 Market Analysis
...
21-05 Market Analysis

Re: Convert Months into numbers?

PostPosted: Sun Aug 08, 2021 12:02 pm
by Luuk
There is many ways to convert both of the month-names and month-abbreviations into their month-numbers.
But if only wanting to conduct filenames like inside of the screenshot, then RegEx(1) is to be the best solution.

First inside of the Filters(12) to put a 'Mask' like *.pdf so then clicking the blue-arrows beside 'Mask' will conduct this filter.
Inside RegEx(1) to put a checkmark in "v2", so this grants using (?X) to say 'Next-Match' or 'Next-Replace', so then its a 'Match' and 'Replace' like...

^(Market Analysis) ([^ ]+ )20(\d\d)( \([^)]+\))?$(?X):Jan(uary)?(?X):Feb(ruary)?(?X):Mar(ch)?(?X):Apr(il)?(?X):May(?X):June?(?X):July?(?X):Aug(ust)?(?X):Sep(tember)?(?X):Oct(ober)?(?X):Nov(ember)?(?X):Dec(ember)?
$3-:$2$1(?X)01(?X)02(?X)03(?X)04(?X)05(?X)06(?X)07(?X)08(?X)09(?X)10(?X)11(?X)12

If you need to match your months better, because some names dont have a month, change ([^ ]+ ) into something more like...
((?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?) )

Re: Convert Months into numbers?

PostPosted: Mon Aug 09, 2021 3:43 am
by amazing
Thanks again! I'm trying to DIY on another set of files here. Why is it that my regex doesn't work?

Image

Re: Convert Months into numbers?

PostPosted: Mon Aug 09, 2021 12:23 pm
by Luuk
Its just because " ([^ ]+ )" looks for "1-or-more non-spaces inbetween two spaces", so that group is not needed for these filenames.
I used ([^ ]+ ) as a shortcut for month names/abbreviations, only because the better month-matcher (at the bottom) was so very long.
And the match was already getting too long to fit onto just 1-line, so then Im just making it with smaller fonts, and with the shortcut.

You could change the "v2" expression by editing ([^ ]+ )20 ===> (\d\d-\d\d-|[^ ]+ )2?0? and using Replace(3) to destroy ':' .
This could let you conduct both formats all at the same time, except that Im not knowing.. What to do with the days?
Im guessing that you always like to keep the days, because \d\d being inside of the parenthesis.

For myself, Im always wanting dates to be in the same format, so Im often use '00' to say 'missing days'.
But then, you would have to edit all of your "v2" replacements like... (?X)01-00(?X)02-00(?X)03-00(?X).

If all of your filenames have either: month-names, month-abbreviations, or month-numbers, like inside of the screenshots?
Then its ok making this "v2" edit to conduct them all, but otherwise must include the very long month-matcher at the bottom.

Re: Convert Months into numbers?

PostPosted: Mon Aug 09, 2021 1:09 pm
by Admin
An alternative method is to rearrange positions inside the file names using Regex with "Simple" flag and then replace month names and year (character translation can also be used for that).