This is all kinds of impractical - the other answers are much faster and shorter - but...
You can use PowerShell! Microsoft open-sourced it recently and made it cross-platform. For downloads and installation instructions for your OS, see the "Get PowerShell" section.
Once you get it installed, you can use this brief script:
Get-ChildItem -File '*]*.avi' | ForEach-Object {
Rename-Item $_ -NewName (($_.Name -Split ']')[0] + '.avi')
}
Basically, it goes through each object in the current directory that is a file matching *]*.avi
, gets the part before the bracket, tacks .avi
back onto it, and assigns that as the new name.
To run it directly from Bash, use this semi-golfed one-liner:
powershell -command $'gci -File \'*]*.avi\'|%{rename-item $_ -NewName (($_.Name -Split \']\')[0]+\'.avi\')}'
Quote escaping courtesy of this Stack Overflow answer.
(Tested in Bash on Ubuntu on Windows. There's probably a much shorter way of doing it with PowerShell, but I wanted to show something that's comprehensible to people who don't know regular expressions.)
krename
is lovely. It has all sorts of powerful options and shows you what it's going to do before it actually does it. You could even use it to test out patterns that you could use in bash later. – Joe Aug 30 '16 at 7:00