Find and replace double spaces with a single space?

Bulk Rename Utility How-To's

Find and replace double spaces with a single space?

Postby kingmustard » Mon Nov 11, 2024 5:12 am

e.g Track 01 Name
to Track 01 Name

Is this possible, as currently, pressing spacebar twice in the 'Replace' field does not detect the double-spaces in the filenames.
kingmustard
 
Posts: 6
Joined: Fri Jan 25, 2019 11:48 am

Re: Find and replace double spaces with a single space?

Postby kingmustard » Mon Nov 11, 2024 5:15 am

kingmustard wrote:e.g Track 01 Name
to Track 01 Name

Is this possible, as currently, pressing spacebar twice in the 'Replace' field does not detect the double-spaces in the filenames.

The forum software stripped the double-spacing from my example.

Hopefully this works (with ALT+0160):

e.g Track 01  Name
to Track 01 Name
kingmustard
 
Posts: 6
Joined: Fri Jan 25, 2019 11:48 am

Re: Find and replace double spaces with a single space?

Postby Admin » Mon Nov 11, 2024 6:37 am

Hi, double space does seem to work in Replace (3) as the standard Space (SP) code 20.
Maybe the file names contain other type of spaces , eg : https://www.compart.com/en/unicode/category/Zs ?
Admin
Site Admin
 
Posts: 2883
Joined: Tue Mar 08, 2005 8:39 pm

Re: Find and replace double spaces with a single space?

Postby kingmustard » Mon Nov 11, 2024 12:19 pm

Admin wrote:Hi, double space does seem to work in Replace (3) as the standard Space (SP) code 20.
Maybe the file names contain other type of spaces , eg : https://www.compart.com/en/unicode/category/Zs ?

Sorry, you are correct!
kingmustard
 
Posts: 6
Joined: Fri Jan 25, 2019 11:48 am

Re: Find and replace double spaces with a single space?

Postby therube » Mon Nov 11, 2024 5:20 pm

It looks like a regex \s space will match most versions of a "space".

So something like,

3:Replace
Code: Select all
Match:  \regex\\s\s
With:  <sp> (an actual spacebar space)


might catch your non-space spaces.

Note that by default, the regex: is global (so it will match all double-spaces in a string).
therube
 
Posts: 1427
Joined: Mon Jan 18, 2016 6:23 pm

Re: Find and replace double spaces with a single space?

Postby Admin » Mon Nov 11, 2024 11:42 pm

This is nice ! 8)
I did not know...
Admin
Site Admin
 
Posts: 2883
Joined: Tue Mar 08, 2005 8:39 pm


Return to How-To