Replace spaces from directory name into -

Advanced Renamer forum
#1 : 10/03-22 14:53
Rob van de St
Posts: 1
I want to replace blanc spaces with - or _ in a directory name.

This name Changed:

Natica eburnea Deshayes- 1838 = Naticarius orientalis -Gmelin- 1791

into

Natica-eburnea-Deshayes--1838-=-Naticarius-orientalis--Gmelin--1791

I found this Link:
https://stackoverflow.com/questions/20791264/how -to-replace-all-spaces-by-underscores-in -all-file-names-of-a-folder

With these 2 bat files, they seem to work.

forfiles /s /m *.* /C "cmd /e:on /v:on /c set \"Phile=@file\" & if @ISDIR==FALSE ren @file !Phile: =_!"
forfiles /s /C "cmd /e:on /v:on /c set \"Phile=@file\" & if @ISDIR==TRUE ren @file !Phile: =_!"


I would rather do it in your program...


edited: 10/03-22 16:16
#2 : 10/03-22 17:50
David Lee
Posts: 1125
It should be obvious -use the Replace method!