#1 2011-04-14 14:23

Rambler
Member
Registered: 2011-04-14
Posts: 5

Regex formula for cleaning up imagevenue files?

Hi,

Helping out my niece with a fashion blog. She's got quite a number of files that seem to be from Imagevenue.

Has someone cooked up a regex formula that cleans off the prefix and suffix stuff?

Here's an example:

"63843_Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07_122_349lo"

"Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07" is the name we want ...


Btw, been using this excellent software for ages - very easy to use - so thanks!

Offline

#2 2011-04-14 16:18

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Regex formula for cleaning up imagevenue files?

Hi and welcome!

FROM:
"63843_Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07_122_349lo"
TO:
"Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07"

DO:
match all signs non-greedy till first underscore: (.+?_)
match all signs till next expression: (.+)
match an underscore, followed by signs, followed by an underscore, followed by signs: (_.+_.+)

Replace with what is matched in group 2 : $2

USE:
1) RegEx: Replace expression "(.+?_)(.+)(_.+_.+)" with "$2" (skip extension)



- - -

If it would make sense for any task one could also use
1) Rearrange: Split by delimiters "_", New pattern "$2_$3_$4_$5_$6_$7" (skip extension)


-

HTH? big_smile


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2011-04-15 02:46

Rambler
Member
Registered: 2011-04-14
Posts: 5

Re: Regex formula for cleaning up imagevenue files?

Thanks Stefan!

Well ... I need to work through some regex tutorials. Atm, it's all magic. wink

OK, with this file ...
Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07.jpg

... I can simply replace "_" with " ". Or replace "ph" with "ph: " etc ... all too easy.


But what about separating words / names? Can regex do this?

If we know that a set of file names uses Proper case
... so that "JuliaStegner" becomes "Julia Stegner"?

Assuming we have a number of files using the same naming pattern, how do we move the name to the start, with the end result like this ?

"Julia Stegner Vogue Italia Setembro 2005 - ph: Richard Burbridge 07"

Last edited by Rambler (2011-04-15 02:48)

Offline

#4 2011-04-15 07:35

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Regex formula for cleaning up imagevenue files?

The tale continues?

Replacing to "ph: " is not an good idea ;-)

- - -

Hint:

RegEx is an pattern matching system, so if your other file names differs from this example my regex may fail.

AND ALWAYS TEST WITH COPIES OF YOUR REAL FILES FIRST!!!

There is no guaranty that i did make it right.

- - -


FROM:
"63843_Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07_122_349lo"
TO:
"Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07"
USE:
1) RegEx: Replace expression "(.+?_)(.+)(_.+_.+)" with "$2" (skip extension)


FROM:
"Vogue_Italia_Setembro2005_phRichardBurbridge_JuliaStegner_07"
TO:
"Vogue Italia Setembro2005 phRichardBurbridge JuliaStegner 07"
USE:
2) Replace: Replace all "_" with " " (skip extension)


FROM:
"Vogue Italia Setembro2005 phRichardBurbridge JuliaStegner 07"
TO:
"Vogue Italia Setembro2005 ph Richard Burbridge Julia Stegner 07"
Hint: regex can do this too: ([a-z])([A-Z]) >> $1 $2, but thanks Denis it is even easier with ReNamer
USE:
3) CleanUp: Insert space in front of capitals (skip extension)
(oh, use the last beta for this feature IIRC)


Now do smtg like:
4) Replace: Replace all " ph " with " ph. " (skip extension)


FROM:
"Vogue Italia Setembro2005 ph. Richard Burbridge Julia Stegner 07"
TO:
"Julia Stegner Vogue Italia Setembro2005 ph. Richard Burbridge 07"
FIND:
All signs till an blank, ==> "(.+)\s" ==> "Vogue Italia Setembro2005 ph Richard Burbridge "
followed by one-or-more signs, followed by an blank, followed by one-or-more signs, ==> "(.+\s.+)" ==> "Julia Stegner"
followed by an blank, followed by one-or-more signs ==> "\s(.+)" ==> " 07"
Hint:
the magic here is that regex works greedy by default and so eat all signs till it is stopped by the next expression defined.
USE:
5) RegEx: Replace expression "(.+)\s(.+\s.+)\s(.+)" with "$2 $1 $3"


- - -
TO:
"Julia Stegner Vogue Italia Setembro 2005 - ph. Richard Burbridge 07"

Question: where comes the blank before the year and the dash "-" from? ;-)

You have to find an common pattern,
f.ex.: always match one-or-more signs followed by four digits followed by an blank ==> .*\d\d\d\d\s
then split this into two parts and add an blank and an additional dash.
That's your homework to do.



HTH? big_smile
If yes,  please see my signature.



.


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#5 2011-04-15 08:32

Rambler
Member
Registered: 2011-04-14
Posts: 5

Re: Regex formula for cleaning up imagevenue files?

OK, "ph:" not a good idea. wink

"Julia Stegner Vogue Italia Setembro 2005 - ph. Richard Burbridge 07"

Question: where comes the blank before the year and the dash "-" from? ;-)

Just a possible Replace iteration ... "ph" to "- ph.", for example.

Thanks so much - it's so much easier with concrete examples seeing how this stuff works! You guys are great.

Will test it out later.

Last edited by Rambler (2011-04-16 03:31)

Offline

#6 2011-04-16 03:42

Rambler
Member
Registered: 2011-04-14
Posts: 5

Re: Regex formula for cleaning up imagevenue files?

OK Stefan .. your efforts have paid off! smile

Just starting to get a hang of greedy expressions (of course, only playing with basic stuff, atm.)

Offline

Board footer

Powered by FluxBB