Page 1 of 1
Search and Replace Switch for Increment On Collision.
Posted: 04 Sep 2010 18:33
by SkyFrontier
This little
script fails for not having this switch (and because of my very limited scripting skills, too

).
Code: Select all
v7.40.0003 - 2008-07-30 12:33
+ Rename Special | Batch Rename. Added switch /i for "Increment On Collision". If you want to automatically avoid collisions with
existing files, append a "/i" to your pattern!
It does make sense adding it to Search and Replace, too (rename s).
Thank you!
Re: Search and Replace Switch for Increment On Collision.
Posted: 05 Sep 2010 13:05
by admin
Not possible because / is already used in the syntax of S&R.
Re: Search and Replace Switch for Increment On Collision.
Posted: 05 Sep 2010 15:29
by SkyFrontier
Admin:
Code: Select all
Not possible because / is already used in the syntax of S&R.
I was afraid of that ( rename s, b/c).
But wondered if it was possible to force XY to see first as search/replacement indicator, next (1 or more) as parameters.
Or anything else: (^i), (*i) - not standard but... "
to hell with standards!"
(man, I *LOVE* such thing...)

Re: Search and Replace Switch for Increment On Collision.
Posted: 05 Sep 2010 15:48
by admin
SkyFrontier wrote:Admin:
Code: Select all
Not possible because / is already used in the syntax of S&R.
I was afraid of that ( rename s, b/c).
But wondered if it was possible to force XY to see first as search/replacement indicator, next (1 or more) as parameters.
Or anything else: (^i), (*i) - not standard but... "
to hell with standards!"
(man, I *LOVE* such thing...)

Currently no time for this... later...
Re: Search and Replace Switch for Increment On Collision.
Posted: 07 Sep 2010 09:55
by admin
I think it would be good to add switches to Search & Replace. To be able to do this the syntax has to be changed in some places. This is my plan. Are there any ferocious objections to this?
Code: Select all
* = changed syntax!
Before:
before/now = replace all 'before' with 'now' (case-insensitive: a=A, ss=ß)
before/now\ = replace all 'before' with 'now' (case-sensitive)
äöü>>aou = replace all ä with a, ö with o, ü with u
Ä|Ö|Ü|ä|ö|ü>>Ae|Oe|Ue|ae|oe|ue = replace all Ä with Ae, Ö with Oe, etc.
[]{};,!>_ = replace each of these characters with _
123>Num = replace all 1, 2, and 3 with Num
[]{};,! = remove all these characters
After:
* before>now = replace all 'before' with 'now' (case-insensitive: a=A, ss=ß)
* before>now /c = replace all 'before' with 'now' (case-sensitive)
äöü>>aou = replace all ä with a, ö with o, ü with u
Ä|Ö|Ü|ä|ö|ü>>Ae|Oe|Ue|ae|oe|ue = replace all Ä with Ae, Ö with Oe, etc.
* []{};,!>>_ = replace each of these characters with _
* 123>>"Num" = replace all 1, 2, and 3 with Num
[]{};,! = remove all these characters
Re: Search and Replace Switch for Increment On Collision.
Posted: 07 Sep 2010 14:30
by SkyFrontier
The only thing I can think of (being *NOT* an experienced scripter) is that
could ruin tons of scripts at once.
The rest seems to be specific changes that may affect one script or another.
Backward compatibility matters but concerning XY Scripts Library, I may be able to track down potentially broken scripts by some changes and at least leave a note at the
index.
EDIT: *ALL* for adding functionality!
Re: Search and Replace Switch for Increment On Collision.
Posted: 07 Sep 2010 15:44
by admin
Yes, back-compatibility is a problem here.
Another suggestion (that leaves the main use case untouched):
Code: Select all
* = changed syntax!
Before:
before/now = replace all 'before' with 'now' (case-insensitive: a=A, ss=ß)
before/now\ = replace all 'before' with 'now' (case-sensitive)
äöü>>aou = replace all ä with a, ö with o, ü with u
Ä|Ö|Ü|ä|ö|ü>>Ae|Oe|Ue|ae|oe|ue = replace all Ä with Ae, Ö with Oe, etc.
[]{};,!>_ = replace each of these characters with _
123>Num = replace all 1, 2, and 3 with Num
[]{};,! = remove all these characters
After:
before/now = replace all 'before' with 'now' (case-insensitive: a=A, ss=ß)
* before/now /c = replace all 'before' with 'now' (case-sensitive)
* äöü/aou /m = replace all ä with a, ö with o, ü with u
* Ä|Ö|Ü|ä|ö|ü/Ae|Oe|Ue|ae|oe|ue = replace all Ä with Ae, Ö with Oe, etc.
* []{};,!/_ /n = replace each of these characters with _
* 123/Num /n = replace all 1, 2, and 3 with Num
[]{};,! = remove all these characters
Re: Search and Replace Switch for Increment On Collision.
Posted: 07 Sep 2010 15:56
by SkyFrontier
Admin:
before/now = replace all 'before' with 'now' (case-insensitive: a=A, ss=ß)
-that DOESN'T mean that you NECESSARILY have to kick out the main idea behind that is *providing parameters to S&R*, right? In case of a "one thing or another" decision, I'd certainly stay with the "add functionality and forget the past" option.
-besides that, I can easily track down the broken scripts and make a note at the Library (Time 2.0 anytime soon, please...?

).
Thank you!
Re: Search and Replace Switch for Increment On Collision.
Posted: 07 Sep 2010 17:06
by Stefan
Admins second suggestion looks nice.
There is an common delimiter between all search and replace pattern
and it looks UN*X like
s/search/replace/flags
Could maybe be extended to
r/RegEx/Replace/flags
k/ABCDEF/_/flags
e/bak/txt/flags
b/New<#1>/flags
?
This syntax will break old scripts too, but i like it.
Maybe the '>' and '>>' delimiter should work a while too along with the new one
but there could be an prompt appearing, telling to use the new delimiter in future.
Re: Search and Replace Switch for Increment On Collision.
Posted: 07 Sep 2010 22:05
by RalphM
I actually preferred the first suggestion. The ">" delimiters looks more like transforming something.
And the difference between:
- ">" = replace the whole string before the delimiter with the string after it and,
- ">>" = replace one by one
was very easy to grasp.
Just my 2 cts
Re: Search and Replace Switch for Increment On Collision.
Posted: 08 Sep 2010 09:16
by admin
RalphM wrote:I actually preferred the first suggestion. The ">" delimiters looks more like transforming something.
And the difference between:
- ">" = replace the whole string before the delimiter with the string after it and,
- ">>" = replace one by one
was very easy to grasp.
Just my 2 cts
The disadvantage of > is that it it used in XY variables. Without it I could allow to add variables to the pattern without getting into parsing trouble.