Search and Replace Switch for Increment On Collision.

Features wanted...
Post Reply
SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Search and Replace Switch for Increment On Collision.

Post 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!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 66361
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Search and Replace Switch for Increment On Collision.

Post by admin »

Not possible because / is already used in the syntax of S&R.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Search and Replace Switch for Increment On Collision.

Post 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...)
:mrgreen:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 66361
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Search and Replace Switch for Increment On Collision.

Post 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...)
:mrgreen:
Currently no time for this... later...

admin
Site Admin
Posts: 66361
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Search and Replace Switch for Increment On Collision.

Post 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

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Search and Replace Switch for Increment On Collision.

Post by SkyFrontier »

The only thing I can think of (being *NOT* an experienced scripter) is that

Code: Select all

(before/now) >> (before>now)
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!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 66361
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Search and Replace Switch for Increment On Collision.

Post 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

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Search and Replace Switch for Increment On Collision.

Post 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...? :wink: ).
Thank you!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Search and Replace Switch for Increment On Collision.

Post 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.

RalphM
Posts: 2090
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Search and Replace Switch for Increment On Collision.

Post 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
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

admin
Site Admin
Posts: 66361
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Search and Replace Switch for Increment On Collision.

Post 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.

Post Reply