Sorry for previous confusion...

I've spent several hours today trying to write a powershell script that will pull a client ID off a PDF from system #1 (example, Smith,John\_H123\_20171012.pdf where the client ID is the *H####* value), then look it up in an Excel spreadsheet that contains the client ID in system 1 and system 2, then rename the file to the format needed for system 2 (xxx\_0000000123\_yyy.pdf).

One gotcha is that client # is 2-4 digits in system 2 and always preceeded by 0's.

Using Powershell and regular expressions.

This is the first part I am trying to use for my initial rename: 

```
    Get-ChildItem -Filter *.pdf | Foreach-Object{
        $pattern = "_H(.*?)_2"
        $OrionID = [regex]::Match($file, $pattern).Groups[1].value
        Rename-Item -NewName $OrionID
    }

```

It is not accepting "NewName" because it states it is an empty string. I have run:

```
    Get-Variable | select name,value,Description

```

And new name shows up as a name but with no value. How can I pass the output from the Regex into the rename?