I need to bulk rename files in a file share that

1. contain a specific character, namely a tilde `~` and
2. have the file extension in capital letters or none at all.

The goal would be to replace the tilde with a simple `-`, keep the file extension, if there is one, but transform it into lowercase letters.

I've had success with the first part of the script that finds the files

```cs
$PATH = "\\<Fileservername>\<Folder>\"
$pattern = "*~*"
Get-ChildItem $PATH -Recurse | where {$_.Name -like $pattern}

```

What I'm struggling with is the second part of the script the renaming.
I've found two topics here:

* [Powershell renaming a specific Character](https://stackoverflow.com/questions/38019236/powershell-renaming-a-specific-character)
* [PowerShell Regex Bulk Replace Filenames](https://stackoverflow.com/questions/49394169/powershell-regex-bulk-replace-filenames)

I haven't been able to adapt those solutions to my need plus there may be additional steps to take in order to convert the given file name from capital letters to lowercase letters or skip this if the file has no file extension.

An example would be to rename `ACUJLH~H` to `ACUJLH-H` and `KYA3BM~Q.PDF` to `KYA3BM-Q.pdf`.