Skip to main content
added 251 characters in body
Source Link

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:

  1. 20211112_CLAM_30001_Important information on xyz_DK
  2. CLAM_DK_20201002_30001_Protocol for PA01 - email
  3. 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?)

Currently im using

dir | Rename-Item -NewName {$_.name -replace "",""}

to rename files in a directory. The file names vary and need to be unified.

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?)

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:

  1. 20211112_CLAM_30001_Important information on xyz_DK
  2. CLAM_DK_20201002_30001_Protocol for PA01 - email
  3. 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?)

Source Link

Powershell: How do I shift a date (format: yyyymmdd) from any position in the file name to end of the file name?

Currently im using

dir | Rename-Item -NewName {$_.name -replace "",""}

to rename files in a directory. The file names vary and need to be unified.

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?)