Powershell regex matching file pattern

Hi guys,

I'm in need of some help with matching file names and appending one file with the other.

To give you an example. We have two files with the same name however, one of the file names ends with _dynamic.txt



I'd like to match files with similar names and append sploaddevicesprint with sploaddevicespint_dynamic.txt

One thing though is that there's more files with the same naming structure however they all use this naming standard.

ANY help will be appreciated.

  • Get-ChildItem | Where-Object { $_.Name -notmatch '.+_dinamic\.txt' } |
        ForEach-Object {
            if (Test-Path $($_.Name + '_dinamic.txt')) {
                Get-Content $($_.Name + '_dinamic.txt') | Add-Content $_