Powershell 删除方括号内

Powershell remove inside square brackets

我有这些名称的文件:

Aaron Wilde - Awaken.mp3
Aaron Wilde - Heroes Collide [Hybrid Orchestral, Action Music].mp3
Aaron Wilde - Into The Fire [Hybrid Orchestral, Heroic, Uplifting Music].mp3
Aaron Wilde - Legacy [Hybrid Orchestral, Vocal, Heroic].mp3
Aaron Wilde - Miracles [Fantasy, Emotional Music].mp3
Aaron Wilde - Together We Rise [Heroic, Orchestral, Battle Music].mp3

我想重命名文件名中不带括号的文件。我试过了,但没用。

 get-childitem *.mp3 | foreach { move-item -literalpath $_.name $_.name.replace("``[*``]","")}
  1. String .Replace 方法用于文字字符串,使用 -replace 运算符。
  2. 而不是 `` 使用 \.* 而不是 *:
    .表示任意符号,*表示0次或多次出现

move-item -literalpath $_.name ($_.name -replace '\[.*\]', '')