2

Good Day

Please help to find the right RegEx or other code for changing file name. Many subtitle files I have unnecessary character. I need to rename in my expectation format. Here the example

Raw File Name

Blue Bloods - 05x05 - Loose Lips.DIMENSION.English.HI.C.updated.Addic7ed.com

Desired File Name

Blue Bloods 5x05 Loose Lips

That means want remove Character

  • 0 (spacebar + 0)

  • (- + space bar)

.DIMENSION.English.HI.C.updated.Addic7ed.com ; remove text anything after first .

Please help me to have the RegEx or any command code for this operation so that i can use it using autohotkey or any command code. Thanks in advance for help

3
  • Your description is incorrect: it gives Blue Bloods -5x05 Loose Lips, or Blue Bloods5x05 Loose Lips if done in reverse order.
    – AFH
    Commented Nov 9, 2014 at 20:25
  • I think Rhinemine means that he wants to remove "0" when it is preceded by space (i.e., replace space+"0" with space). Commented Nov 11, 2014 at 1:17
  • I don't use Windows or AutoHotKey, but if you can get any version of sed for your system, it's perfect for cleaning up pesky text data like this. It has very powerful regex support. You can also just set it up with constant sample texts going into it until you get your regex to work properly. I know cygwin supplies all the tools like this, but you can probably find a standalone sed for Windows as well. thoughtasylum.com/blog/2011/9/30/using-sed-on-windows.html
    – Joe
    Commented Nov 11, 2014 at 2:30

1 Answer 1

1

Reading your question I assume that your generic format is

<strictly-alphanumeric string of arbitrary length greater 0> - <number of at least 1 digit>x<number of at least 1 digit> - <strictly-alphanumeric string of arbitrary length greater zero>.<random sequence>

This can be solves with the following Regex:

^([\w ]+) - 0*([1-9]+\d*)x(\d+) - ([\w ]+)\..*$

group one will contain "Blue Bloods", group two will contain "5", group three will contain "05" and group four will contain "Loose Lips".

To assemble it to the correct syntax, replace by

\1 \2x\3 \4

This has been tested in notepad++ with your example string.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .