1

I have been attempting to modify the following example given for a similar question in Powershell, to match my own needs. Running the example works fine.

Please could you assist in how to change the code for my needs below?

Example given:

~$test = '1942.009.405_SIENESE 16TH CENTURY__1988_09_08_DATA REPORT_TX_4305010_0002.pdf'~

~$test -replace '^(.+\d{4})_(\d{2})_(\d{2}.+)$', '$1-$2-$3'~

Result:

1942.009.405_SIENESE 16TH CENTURY__1988-09-08_DATA REPORT_TX_4305010_0002.pdf

I want to modify this code so that filenames like:

DDG376-Run1-432.21-543.32 (1)

to become:

DDG376 - Run 1 - 432.21-534.32 (1)

I would imagine if I could replace (.+\d{4}) with a search for ANY character string up to 6 characters, a hyphen, 4 characters, hyphen, (remainder) and then replace the hyphens with SPACE hyphen SPACE it would work. I don't know how to make the digit search an 'any character string' search.

Any assistance would be amazing.

Adam W
  • 11

0 Answers0