Rename Special modify _to Spaces script request

Discuss and share scripts and script files...
JimXYUser
Posts: 23
Joined: 23 Nov 2012 00:26

Rename Special modify _to Spaces script request

Post by JimXYUser »

the Right-Click -> Rename Special has a

_ to Spaces

can some1 help me with a script that add more then just replacing the underscore? I wanted it to replace - and + as well, with space.

e.g. filename_has-this_and+this.exe
change to:
filename has this and this.exe

Can i extend the Rename Special to make the changes above? thanks.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Rename Special modify _to Spaces script request

Post by j_c_hallgren »

Hi and welcome to the XY forums!

Have you looked at using the existing "Search and Replace" variant instead? I believe that would do it...
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename Special modify _to Spaces script request

Post by highend »

Have you looked at using the existing "Search and Replace" variant instead?
What he said^^

Code: Select all

_-+>space
Just replace the space with a real one in the search and replace dialog window.
One of my scripts helped you out? Please donate via Paypal

JimXYUser
Posts: 23
Joined: 23 Nov 2012 00:26

Re: Rename Special modify _to Spaces script request

Post by JimXYUser »

where can i find "Search and Replace"? I only able to get F3 (quick search) and F12 (search location).

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename Special modify _to Spaces script request

Post by highend »

Em, right click a file, Rename Special, Search and Replace...?
One of my scripts helped you out? Please donate via Paypal

JimXYUser
Posts: 23
Joined: 23 Nov 2012 00:26

Re: Rename Special modify _to Spaces script request

Post by JimXYUser »

thanks highend, for letting me know where is the "Search and Replace".


But by using "Search and Replace" i need to type in each time i wanted to do a replacement. would it be better if i have a script to do it.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Rename Special modify _to Spaces script request

Post by j_c_hallgren »

JimXYUser wrote:thanks highend, for letting me know where is the "Search and Replace".
I normally access it via File>Rename Special menu for the selected file
But by using "Search and Replace" i need to type in each time i wanted to do a replacement. would it be better if i have a script to do it.
Previously used S&R strings are stored and available via dropdown at right end so not much retyping....
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

JimXYUser
Posts: 23
Joined: 23 Nov 2012 00:26

Re: Rename Special modify _to Spaces script request

Post by JimXYUser »

manage to find the answer, put this code in User -> Manage Commands -> location, then set a hot key.
now each time i select some files, press the hot key and all files will be formatted with empty space.
rename s, "-/ "; rename s, "_/ "; rename s, "+/ ";

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Rename Special modify _to Spaces script request

Post by j_c_hallgren »

JimXYUser wrote:manage to find the answer, put this code in User -> Manage Commands -> location, then set a hot key.
now each time i select some files, press the hot key and all files will be formatted with empty space.
rename s, "-/ "; rename s, "_/ "; rename s, "+/ ";
Why do you have 3 separate renames? Won't one with "-+_/ " work just as well?
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

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

Re: Rename Special modify _to Spaces script request

Post by admin »

This way, please:

Code: Select all

rename s, "+-_> ";

JimXYUser
Posts: 23
Joined: 23 Nov 2012 00:26

Re: Rename Special modify _to Spaces script request

Post by JimXYUser »

why '/' can be replace by '>' ?

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

Re: Rename Special modify _to Spaces script request

Post by admin »

JimXYUser wrote:why '/' can be replace by '>' ?
I has to be replaced else it does not work. :) Check out the Help...

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Rename Special modify _to Spaces script request

Post by PeterH »

Oh dear, I'm multiple confused now :?

I didn't really understand the help for the Scripting Command "Rename". (That's what we are talking about.) Description of operand "pattern" says: "[Required] The pattern to be applied. Its syntax may vary depending on which mode is used, see below for more." But "below" I find almost nothing...

Then I had the idea to look for help for the Menu Command "Rename" - but: this is not so easy to find - it doesn't seem to exist in any way in Contents (German: "Inhalt") of Help.
But if you search for "Rename" either by "Index" or by "Search" (German: "Suchen") you can find it. It's "File Menu / Rename Special (Submenu)"

So I think you should
1) give a hint (and maybe a direct link) in "Scripting Command / Rename" to "File Menu / Rename Special (Submenu)", and
2) in the index of help there should be a chapter for "Menu Commands", with entries for help pages like "File Menu".


Just another point: shouldn't the first operand for the Rename scripting command (in the examples) be quoted for clean syntax, i.e. "s"?

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

Re: Rename Special modify _to Spaces script request

Post by admin »

1) give a hint (and maybe a direct link) in "Scripting Command / Rename" to "File Menu / Rename Special (Submenu)", and
Already there.

Just another point: shouldn't the first operand for the Rename scripting command (in the examples) be quoted for clean syntax, i.e. "s"?
Yes, but in the case of one-letter flags one can be a bit tolerant. :)

The "i" button in the Rename Special dialogs contains all necessary information.

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Rename Special modify _to Spaces script request

Post by PeterH »

admin wrote:1) give a hint (and maybe a direct link) in "Scripting Command / Rename" to "File Menu / Rename Special (Submenu)", and
Already there.
Me bad :oops: Even with a link! :appl:
But I've stopped reading after having reached the example for "rename s, ..." :whistle:
I'm afraid this happens to others, too? So maybe it would be better to include it more at the top - for example direct behind the bold word Syntax?
admin wrote: Just another point: shouldn't the first operand for the Rename scripting command (in the examples) be quoted for clean syntax, i.e. "s"?
Yes, but in the case of one-letter flags one can be a bit tolerant. :)
My impression is that people often have problems with quoting strings. I just don't think it helps when strings sometimes are shown unquoted.

And I think I remember that severals months ago you said that you cannot guarantee that unquoted strings maybe lead to errors in the future...

Though I must say: for these option-letters it looks better if they are unquoted :-(

Post Reply