Rookie question. Following this answer Move last part of filename to front, I'm trying to do the same, except all files in my case contains square brackets.
What I want is to move the title to the other side of the brackets (keeping the file extension), so this: title ![s2_e2].mp4 renames to this: [s2_e2]title !.mp4
The first part may contain exclamation marks and spaces, but no other characters which need to be escaped.
I have come up with this, but it only removes the filename until the first square bracket: rename -n 's/^.*\[//' *
Am I on the right path here? And how can I accomplish it with the perl rename tool on Linux?
Thanks!
renamesupport (or need) that--. A more portable approach would be to use./*.mp4. Also, inrenameyou generally want to use thesflag to thesubstitute command as otherwise.would not match on the newline character. – Stéphane Chazelas Feb 06 '22 at 14:25--, I'll undo the others. – terdon Feb 06 '22 at 16:09