Hello All
I'm using RegEx to rename a lot of files. Following are some samples of the filename.
Code:
$ ls -1N
01 Linux OS Introduction12m 58s.mp4
02 Subject Intro25s.mp4
03 Learning Objectives23s.mp4
04 Final Analysis3m 12s.mp4
I want to replace characters in bold to nothing. So, the regular expression I'm using is this. I'm also using Positive Lookahead Assertion for safety.
Code:
([0-9]{1,2}[sm]{1}) ?([0-9]{1,2}[sm]{1})?(?=\.mp4$)
Code:
$ prename -nv 's/([0-9]{1,2}[sm]{1}) ?([0-9]{1,2}[sm]{1})?(?=\.mp4$)//' *.mp4
01 Linux OS Introduction12m 58s.mp4 -> 01 Linux OS Introduction.mp4
02 Subject Intro25s.mp4 -> 02 Subject Intro.mp4
03 Learning Objectives23s.mp4 -> 03 Learning Objectives.mp4
04 Final Analysis3m 12s.mp4 -> 04 Final Analysis.mp4
Is this the correct way? Or can I optimize/shorten RegEx even better?
Thanks