#1 2011-12-26 22:27

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

Replace rule: add option to work on N'th occurrences only

Now and then i came across an request to REPLACE only the n'th occurrence of an sign,
and i always wonder why ReNamer has no such feature ( i searched the forum if i have suggested
that once again, but could not find anything about this issue)



So for example i want to replace the second hyphen only in this file name:

FROM:
SpongeBob - S01E17 - Die Schatzsuche - Bus verpasst.ext

TO:
SpongeBob - S01E17, Die Schatzsuche - Bus verpasst.ext


Therefore we can use an script but have to ask the user to change the script parameters
always to suit the needs or use an regex. But i want to make it easy for average users.





So i want to suggest to improve the REPLACE rule to add parameters to
- start replacing at n 'th occurrence found
- replace n occurrences


Find:      [  -  ]
Replace: [  + ]
( )All
( )First
( )Last
(o) Advanced:  start at [   2]'th occurrence and replace [   1] occurrences





- - -

What do you think?


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

#2 2011-12-27 04:14

narayan
Senior Member
Registered: 2009-02-08
Posts: 471

Re: Replace rule: add option to work on N'th occurrences only

For a non-expert user, it would be easier to reconstruct the names by using the following "Replace" pattern-

$1 - $2, $3 - $4

(Provided that the structure of all files is the same.)

Last edited by narayan (2011-12-27 04:15)

Offline

#3 2011-12-27 13:02

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

Re: Replace rule: add option to work on N'th occurrences only

Good idea.
But i don't see how this would be easier "For a non-expert user"

What narayan suggests, was to use "[X] Interpret * as wildcards"
and split the input string into parts at the hyphens
by using an Find expression like "* - * - * - *"
and an Replace pattern like "$1 - $2, $3 - $4"
where we get back by the $1 signs what is captured by the * stars
while adding the hyphens at our own, but using an coma instead of the second hyphen.


I must say i think i never used this wildcards but have to remember this for the future.


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

#4 2011-12-27 21:37

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 356

Re: Replace rule: add option to work on N'th occurrences only

Stefan wrote:

What do you think?

I'm for simplifying any option that could be done in that way. I like your suggestion and think it's feasible.

Stefan wrote:

So i want to suggest to improve the REPLACE rule to add parameters to
- start replacing at n 'th occurrence found
- replace n occurrences

You missed that you can add it to Remove rule also. smile

After some thinking you get one step further cause there could be numerous occurrences.
Your preposition for that option is good in case that someone want to remove from 2nd till 5th but you can have this case that someone want to remove 2nd, 5th and 7th for instance. What then?

Well, I will suggest to create type box using dimensions like in Delimiter option from Delete rule.
Separator could be *|* as it is in those rules. You type numbers/occurrences 1*|*4*|*6 in really "customized" way or 2*|*3*|*4 etc. in "From Until" (your thought) manner...

Note: If someone wants to replace from 3 till 50 occurrences (Analyze dialog example) then we can use dash "-" as instruction I guess? If you guys want to add more patterns you can do it as you said using commas.

So allowed characters would be numbers, dash, comma and separator sign *|* without space. Other characters should be disabled to avoid errors. To notify user what is allowed balloon message from type box could pop up. Let's see how it should look like:

Find:      [  -  ]
Replace: [  + ]
( )All  ( )First ( )Defined: (type box) ( )Last

or in Remove rule

Remove: [ - ]
( )All  ( )First ( )Defined: (type box) ( )Last

Denis could create Alpha version so we can test it in all possible scenarios.
What do you think people? If I missed something I would like to hear smile

Last edited by eR@SeR (2011-12-27 21:41)


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

Board footer

Powered by FluxBB