Reputation: 1899
(Bash newb here; my apologies.)
I have a folder of a couple hundred files like
"Cool Stuff - Some Movie Series #14.mp4"
"Other Stuff - Some Movie Series #49.mp4"
"Further Stuff - Some Movie Series #48.mp4"
and so on.
I'd like to mass rename them to be, respectively
"14 Cool Stuff - Some Movie Series.mp4"
"49 Other Stuff - Some Movie Series.mp4"
"48 Further Stuff - Some Movie Series.mp4"
and so on.
Is there a straightforward way to do this?
(One solution that may or may not be promising is to use rename
. For example, rename 's/Movie/Mxvxx/g' *
would replace the vowels with x
s. But what I'm unable to do with that strategy is assign the numbers that come between the #
and the .mp4
to a variable that I then prepend to the filename. So I fear that rename
is a misguided strategy.)
Upvotes: 0
Views: 56
Reputation: 88543
I assume the quotation marks are not part of the filename.
prename -n 's/(.*) #(.*)\.mp4/$2 $1.mp4/' *.mp4
Output:
Cool Stuff - Some Movie Series #14.mp4 renamed as 14 Cool Stuff - Some Movie Series.mp4 Further Stuff - Some Movie Series #48.mp4 renamed as 48 Further Stuff - Some Movie Series.mp4 Other Stuff - Some Movie Series #49.mp4 renamed as 49 Other Stuff - Some Movie Series.mp4
If output looks okay, remove -n
.
Upvotes: 1