Rename files so that it only contain numbers

I have a bunch of files that looks like this:

[Skymoon Raws] Mushoku Tensei - 06 [ViuTV][WEB-DL][1080p][AVC AAC].mp4
[Skymoon Raws] Mushoku Tensei - 07 [ViuTV][WEB-DL][1080p][AVC AAC].mp4

And I want it to look like this:

061080.mp4
071080.mp4

Remove all occurrence of "1080" if possible.


Solution 1:

Renaming files by wildcard pattern.

mmv '* Mushoku Tensei - * \[*\]\[*\]\[*p\]*' '#2#5.mp4'
                        ^             ^
                        2             5

The order of a wildcard character or a range pattern will be represented by a number sign in the to pattern.

  • ; Expands to any number of directories (same as **/).
  • * Matches any character zero or more times.
  • ? Matches any single character.
  • [] Matches a list or and a range of characters.
  • # References to the nth wildcard char in the from pattern.