Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Things you’d like to miss in the future...
Post Reply
Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by Jerry »

When there are an odd number of the same letter in a row, with all but the last letter uppercase, search and replace of "Xx" to "XX" does not change the last lowercase character. For example using the expression "Xx/XX" in Rename Special > Search and Replace,
  • XXx-abx.txt does not change at all
    XXx-Xx-abx.txt changes to XXx-XX-ab.txt instead of XXX-XX-abx.txt
    XXXx-abx.txt changes to XXXX-abx.txt [ok]
    XXXXx-abx.txt does not change at all
    XXxxx-abx.txt changes to XXXXx-abx.txt instead of XXXXX-abx.txt
So if this is a feature and not a bug, I have to do one rename of Xx/XX for even counts and XXx/XXX for the odd counts?

[Using 17.50.0218]
Last edited by Jerry on 17 Feb 2017 16:21, edited 1 time in total.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

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

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by admin »

Confirmed! Fascinating!! :ugeek: Going to work... :cup:

Gandolf

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by Gandolf »

I don't totally agree with the last example.

I think that XXxxx-abx.txt should change to XXXxx-abx.txt, unless you are talking about a recursive replace.

I'm not on a system that will run XY at the moment so can't read the help file to see if the function is recursive by default.

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

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by admin »

Not as fascinating as I thought but simply a user error. For this to work the replacement should be case-sensitive!

It's done with a switch like this:

Code: Select all

Xx/XX /c
And Gandolf is right, XXxxx-abx.txt is renamed to XXXxx-abx.txt. All others end up with all capital Xs.

Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by Jerry »

Gandolf wrote:I think that XXxxx-abx.txt should change to XXXxx-abx.txt, unless you are talking about a recursive replace.
Actually, I think I agree with you on that; not sure why I included that example.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by Jerry »

admin wrote:All others end up with all capital Xs.
Without the /c switch, right?
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

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

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by admin »

No, with the switch.
Attachments
2017-02-17_163944.png
2017-02-17_163944.png (10.17 KiB) Viewed 1550 times

Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by Jerry »

Are you saying there is no bug here afterall?
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by highend »

There isn't.
One of my scripts helped you out? Please donate via Paypal

Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's

Post by Jerry »

Ok, I guess the rule to remember here is that the string matching proceeds from left to right with no overlapping. So the "Xx" matches the first XX, takes those 2 characters out of consideration for further matching and moves along. This is also the way Notepad does its case-insensitive search and replace too.

But it does seems surprising initially to see the string "Xx" appear in a name and find that the basic case-insensitive search and replace may not work on it, if that string does not appear in isolation from other "X's". Understandable, but surprising.

Case closed.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

Post Reply