I am trying to replace all the file names in the folder that have the year different than 2021.
Example:
some_random_text_20240102 --> some_random_text_20210102
some_random_text_20220320 --> some_random_text_20210102
some_random_text_20241020 --> some_random_text_20210102
The only digits are at the end of the file's name. The year represents the first 4. I can't figure out how to add this to the logic (haven't done regex before)
Get-ChildItem -Path "." -Filter "*.csv" | Rename-Item -NewName { $.BaseName.Replace("20[0-9][0-9]","2021") + $.Extension }