Inline Rename Help : Replace selected space with a dash?

Hello!

Is there a script or RegEx code to replace any selected space in the file/folder name with a dash and space before it and after it like that : ( – ) Or ( β€” )

The Result :-

Thanks! :slight_smile:

Not a RegEx but you could type:
Alt + 0150 (en dash) or
Alt + 0151 (em dash),
if it's just for occasional application.

Try

<?xml version="1.0"?>
<regexsel key="ctrl+X" name="Replace by β€”">
	<eval>if (len(valsel) &gt; 0 ) {
	selstart = Len(valleft) + 1;
	selend = selend + 2;
	return valleft + &quot; β€” &quot; + valright;
}</eval>
</regexsel>

You can use a rename key:

selend = selend + 2;
valleft + Replace(valsel, " ", " β€” ") + valright
XML
<?xml version="1.0"?>
<regexsel key="ctrl+shift+S" name="space2dash">
	<eval>selend = selend + 2;
valleft + Replace(valsel, &quot; &quot;, &quot; β€” &quot;) + valright</eval>
</regexsel>

Paste in Preferences / File Operations / Renaming Files / Control Keys

Unfortunately ..
I'm using many hotkeys with sequence keys so when i try to type (Alt + 0150) for example i got this error massage every time so i need alternative way like Inline Rename to work around

That’s what the other two replies give.

Works perfectly!

Thanks :rose:

Great!

Please can you modify it to replace any selected characters or spaces whatever it is length?

Doesn't @AlbatorV's rename key do this?

Just an update to select " β€” " after renaming.

<?xml version="1.0"?>
<regexsel key="ctrl+X" name="Replace by β€”">
	<eval>if (len(valsel) &gt; 0 ) {
	selstart = len(valleft);
	selend = len(valleft) + 3;
	return valleft + &quot; β€” &quot; + valright;
}</eval>
</regexsel>

Yes! :+1:

Excellent!
Thanks