Currently im using
dir | Rename-Item -NewName {$_.name -replace "",""}
to rename files in a directory. The file names vary and need to be unified.
Examples for file names:
- 20211112_CLAM_30001_Important information on xyz_DK
- CLAM_DK_20201002_30001_Protocol for PA01 - email
- DK_30001_Update on customer increase_signed_20220102
Unified format:
CLAM_30001_Arbitrary text_yyyymmdd
There is a date as an 8 digit no. at an arbitrary position in the file name. The date needs to be the very end of the file name. How can I move it to the end? (Perhaps REGEX?)
$_.name -match '(19|20\d{2})(\d{2})(\d{2})'
or another regex of your choice - you will have the complete date in$Matches[0]
and you can put it wherever you want