-2

While doing bulk renaming mistakenly I removed periods from extensions of many of my files and also it duplicated the extensions in every file

Now I would like to add them back

My Files look like this now

A Nightmare On Elm Street 720p Bluray X264-Pahe In mkv mkv
Austin Powers International Man Of Mystery 480p Bluray 300mb-Pahe In mkv mkv
Death_warrant_1990_720p_bluray_x264_750mb-Pahe In mkv mkv
Die Frau Des Polizisten 720p Bluray X264-Pahe In mkv mkv

So What I would like to do is remove the extra extension part, as well as add a period just before the extension so that it will look like a video file

That is..once I rename it should look like below

A Nightmare On Elm Street 720p Bluray X264-Pahe In.mkv
Austin Powers International Man Of Mystery 480p Bluray 300mb-Pahe In.mkv
Death_warrant_1990_720p_bluray_x264_750mb-Pahe In.mkv
Die Frau Des Polizisten 720p Bluray X264-Pahe In.mkv

Is there any regex that I could use? or can I use perl rename technique with regex to do so?

brian d foy
  • 121,466
  • 31
  • 192
  • 551
roshan
  • 25
  • 6

1 Answers1

0

You can try:

s/^(.*) (\w\w\w) (\2)$/\1.\3/

Demo 1

Or, this works too:

s/ (\w\w\w) (\1)$/.\1/

Demo 2

dawg
  • 80,841
  • 17
  • 117
  • 187