I want the following files to be renamed removing the sequence numbers.01 X.mp3 to X.mp302 Add Me In.mp3 to Add Me In.mp3I am trying with the below rename command.rename -v -n 's/^\d+\s*([a-z]+\.mp3)$/$1\.mp3/' *.mp3Running this command gives me this error:Using expression: sub { use feature ':5.18'; s/^\d+\s*([a-z]+\.mp3)$/$1\.mp3/ }Can anyone help me understand the error?
Renaming using terminal and regexp to remove leading numbers from filenames
shell;regular expression;rename;macintosh
I don't see why that error would occur. In fact, I am reasonably certain there were more lines to the error than you show; for one thing, there's no actual error message. However, that regular expression won't actually match either of your example files. You are using [a-z]+\.mp3 which will only match lower case letters and, since you're matching all the way to the extension, it will only match files whose name consists of only lower case letters after the numbers and space you want to remove. You could instead match [a-zA-Z] or use s///i to make the match case insensitive, but it would be a better idea to not match the rest of the word at all. You just want to remove the digits and whitespace from the beginning, so just match those:rename -vn 's/^\d+\s+//' *mp3