title: Remove all following characters after the second occurence of a string in a filename with Powershell
body: <p>In my music library I have filenames like this:</p>
  <ol>
  <li>Artist - Song (feat. OtherArtist) (feat. OtherArtist).mp4</li>
  <li>Artist - Song (feat. OtherArtist) (Radio Edit) (feat. OtherArtist).mp4</li>
  </ol>
  <p>What I want is to remove the duplicate feature mention at the end. This is what I came up with so far:</p>
  <p><code>Get-ChildItem -Path &quot;path&quot; -Recurse -Filter *feat*feat* | ForEach-Object { $_ | Rename-Item -NewName $_.Name.SubString(0,$_.Name.Length -10) } </code></p>
  <p>This gets all the files with dublicate features and then just removes the last 10 characters (including the file extension unfortunately), which cleary wont work if the song features multiple artist or even artist with longer names.</p>
  <p>I think I need <strong>regular expressions</strong> for this, but I'm still at most a beginner in using  Powershell, so I would be really thankful for some help.</p>