I need to get the ''year'' info (2022 or 2023, if has both 2022 and 2023, get the first one; the file name may contain 2024 or 2025 in the future) from the file name.
Unfortunately that'll also match "MyFile-20-01-1999.txt", "20 Ways to get to the Top.pdf", etc. You really do need to pattern match, and even then will need reasonably consistent file name structures to match against...
That's true and well spotted, but if I change the search string a little to the one I should of used originally, I find all the filename examples given in the original post but not the samples you gave.
find . -iname '*202*.*' -print
There will always be exceptions of course, but this should get 'som' a fair way and maybe he could use the command a few times using different search strings in a Run Shell Script action.
You can expand that further and catch both "delimited with year first" and "delimited with year last" forms.
Where it will fall down is with eg "science 20121999.pdf" -- it's obvious to us that the year is "1999", but you'd have to build extra logic into your pattern to infer day and month digit-pairs, assess their validity, work out the date format, etc. At which point you're probably better off sanitising the data beforehand!