#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Pro's please help with regular expression


    hi,

    tried to find a solution with searching in forums and google.... maybe it's a bit to complex....

    obviously for me

    ###

    I have to replace many files, for example:

    COP_LAND_HDTV_ARD.ts to: COP_LAND_[HDTV]_[ARD].ts
    BRAEUTE_SDTV_3SAT.ts to: BRAEUTE_[SDTV]_[3SAT].ts
    FRANZ_UND_ANNA_HDTV_ORF2.ts to: FRANZ_UND_ANNA_[HDTV]_[ORF2].ts

    I mean basically the next to last
    "_" should be replaced with: "_["

    the last "_" should be replaced with: "]_["

    and ".ts" should be replaced with "].ts"

    ...... any ideas with what kind of pattern i could do this ??
    (I use better file rename)

    thx in advance for help !
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,068
    Rep Power
    9398
    I'd say something about those filenames but I know it wouldn't change anything.

    Use
    Code:
    ^(.*)_([^_]+)_([^_]+)\.ts
    to match...
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0
    requinix,

    first of all: thank you very much for your help !

    as i'm really a beginner.... at first I didn't understand anything !!

    ###

    but after some trial and error, I figured out what I had to do - you are awesome !!! - thx thx thx

    and for other "beginners":

    in better file rename

    change: entire file name
    action: replace using regular expressions

    pattern: ^(.*)_([^_]+)_([^_]+)\.ts
    substitution: \1_[\2]_[\3].ts

    ###

    and just cause i'm curious....
    what you'd say about the filenames ??
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,068
    Rep Power
    9398
    It's nothing, don't worry about it.

    I gave you half of the answer because I thought you could come up with the other half by yourself. And you did

IMN logo majestic logo threadwatch logo seochat tools logo