Sample Header Ad - 728x90

Rename file with the rename tool - moving around square brackets

3 votes
2 answers
1029 views
Rookie question. Following this answer https://unix.stackexchange.com/questions/444825/move-last-part-of-filename-to-front/444826#444826 , 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!
Asked by Nicolas Ø (45 rep)
Feb 5, 2022, 02:00 PM
Last activity: Feb 6, 2022, 04:25 PM