Adding / Removing Hyphens Between Names in File Names

A swapping-ground for Regular Expression syntax

Adding / Removing Hyphens Between Names in File Names

Postby Guy » Fri Mar 14, 2025 12:20 pm

Hi

I would like to insert hyphens between names for file names that consist of more than one name, ensuring there are no spaces before or after the hyphens.

Thank you!

Before:
Setting the Data Type in Python.html

After:
Setting-the-Data-Type-in-Python.html
Guy
 
Posts: 19
Joined: Wed Jan 19, 2022 8:27 am

Re: Adding / Removing Hyphens Between Names in File Names

Postby therube » Fri Mar 14, 2025 4:34 pm

3:Replace
Code: Select all
Replace: <sp>  (don't type <sp>, literally enter a "space")
With:  -



(Now, if you had consecutive spaces in a file name, you might have to go about it a bit differently...)
therube
 
Posts: 1427
Joined: Mon Jan 18, 2016 6:23 pm

Re: Adding / Removing Hyphens Between Names in File Names

Postby Guy » Fri Mar 14, 2025 4:52 pm

therube wrote:3:Replace
Code: Select all
Replace: <sp>  (don't type <sp>, literally enter a "space")
With:  -



(Now, if you had consecutive spaces in a file name, you might have to go about it a bit differently...)



Cool, forgot “Replace” section can do it. Thank you!
Guy
 
Posts: 19
Joined: Wed Jan 19, 2022 8:27 am


Return to Regular Expressions