Add Spaces to every dash in a file name

Hi All

I've modified Leo's Dot's to spaces vbscript slightly to make it add a space before and after every dash in a file name.

For example, say you have a music album that has:

01-Michael Jackson-Billie Jean.mp3
02-Michael Jackson-Beat It.mp3

It will rename it to:

01 - Michael Jackson - Billie Jean.mp3
02 - Michael Jackson - Beat It.mp3

making it easier to read and neater.!!!

Warnings/limitations

Might not be useful when:

  1. Renaming files/folders that have numbers eg. 02-06-1982.

  2. Renaming music artist who use dashes in their names eg. Jay-z, Ja-Rule.

  3. Files/folders that have multiple dashes e.g --, --- (solution for this is to use Scred alternative button instead(see below post)) [/b]

99% Credit goes to Leo

:smiley:
Cheers All

Download the rename preset:

Hello KingOfDaClick,

I'm guessing that you hacked Leo's VB script and then modified it to add a space before and after every dash in a file name.

Your solution, probably unknown to you, if I understand your post correctly, actually is better than you may think.
You ALMOST got a more advanced solution !

What regexp would add spaces around '-' characters, but keep an ellipsis such as -- or --- intact ?

As a button I use

@NoDeselect 
Rename REGEXP PATTERN="(.*)(([^ -])(-)|(-)([^ -])|  )(.*\..*)#" TO="\1\3\5 \4\6\7" type=files
Rename REGEXP PATTERN="(.*)(([^ -])(-)|(-)([^ -])|  )(.*)#" TO="\1\3\5 \4\6\7" type=dirs

This also collapses multiple space characters.

The regexp part of your vb script then becomes:

' Apply our regular expression to the filename.
re.Pattern = "([^ -])(-)|(-)([^ -])"
strNameOnly = re.Replace(strNameOnly, "$1$3 $2$4")

I think that's correct vb expession.
I haven't checked it yet though.

And your solution was

' Apply our regular expression to the filename.
re.Pattern = "([^ - ])\-|\-([^ - ])" 
strNameOnly = re.Replace(strNameOnly, "$1 - $2")

Kind Regards,
Scred

Hey Scred
thanks for sharing ur script/button, it worked like a charm, slightly better alternative.

Please share any other scripts u may have under your belt....

Cheers,
KingOfDaClick