$ dir
Magi The Labyrinth Of Magic Episode 1 English Dubbed.mp4
Magi The Labyrinth Of Magic Episode 2 English Dubbed.mp4
Magi The Labyrinth Of Magic Episode 3 English Dubbed.mp4
Magi The Labyrinth Of Magic Episode 4 English Dubbed.mp4
Magi The Labyrinth Of Magic Episode 5 English Dubbed.mp4
Magi The Labyrinth Of Magic Episode 6 English Dubbed.mp4
Magi The Labyrinth Of Magic Episode 6 English Dubbed.mp4-1.part
$ rename -n 's/Magi\ The\ Labyrinth\ Of\ Magic\ Episode\ {1..5}.+mp4/MTLOM\ \(DUB\)\ 0*{1..5}.mp4/g' *
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/Magi\ The\ Labyrinth\ Of\ Magic\ Episode\ { <-- HERE 1..5}+mp4/ at (eval 1) line 1.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/Magi\ The\ Labyrinth\ Of\ Magic\ Episode\ { <-- HERE 1..5}+mp4/ at (eval 2) line 1.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/Magi\ The\ Labyrinth\ Of\ Magic\ Episode\ { <-- HERE 1..5}+mp4/ at (eval 3) line 1.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/Magi\ The\ Labyrinth\ Of\ Magic\ Episode\ { <-- HERE 1..5}+mp4/ at (eval 4) line 1.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/Magi\ The\ Labyrinth\ Of\ Magic\ Episode\ { <-- HERE 1..5}+mp4/ at (eval 5) line 1.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/Magi\ The\ Labyrinth\ Of\ Magic\ Episode\ { <-- HERE 1..5}+mp4/ at (eval 6) line 1.
I want to rename some files and not others; out of 30 files, files to be ignored are the sixth 6, 16, 8, 28 and 19.
To rename all but files 6, 8, 16, 19 and 28 if there are 30 files in total:
Using
()
to save the pattern and$1
to reference it. I am not sure what you want to happen with the0*
in your replacement - I just took it out. Adjust as desired.I took out the unnecessary escapes
Note on regex
-
[^68][^689]?|18|26|29
match any char but6
or8
followed optionally by any char but6
,8
, or9
, or, match18
, or, match26
, or, match29
. Not very elegant...