Batch file to get rid of spaces in ROM filenames

General chit-chat about what's hot and not in the land of emulated video games.

Moderator: dee2eR

Post Reply
NoJive
Contributing Member
Contributing Member
Posts: 25
Joined: Mon Aug 27, 2018 6:26 am

Batch file to get rid of spaces in ROM filenames

Post by NoJive » Mon Dec 31, 2018 2:13 pm

If anyone has a crap ton of ROMs that will not scan due to spaces in the filenames, this might just help out. Make a batch file with the following text, and put the file in whatever ROM directory you want changed. This replaces spaces in the names with underscores, and will do this on every file in the directory. If you want to force it to only change, say .zip files, you can do this by replacing the *.* with *.zip, or whatever extension you wish:

Setlocal enabledelayedexpansion

Set "Pattern= "
Set "Replace=_"

For %%a in (*.*) Do (
Set "File=%%~a"
Ren "%%a" "!File:%Pattern%=%Replace%!"
)

Pause&Exit

dee2eR
Inventor
Inventor
Posts: 1872
Joined: Tue Aug 22, 2017 2:07 pm

Re: Batch file to get rid of spaces in ROM filenames

Post by dee2eR » Tue Jan 01, 2019 2:05 pm

Thanks for posting that, great idea. It's probably also useful for images. With some tweaking it could be worth adding that as an option in the service menu (although could also be disastrous if it goes wrongly...)

guntherm
Super Contributor
Super Contributor
Posts: 96
Joined: Sun Nov 11, 2018 8:58 am

Re: Batch file to get rid of spaces in ROM filenames

Post by guntherm » Tue Jan 01, 2019 2:08 pm

I like that idea of adding it.. but you are right.. could be harmful.. lol

NoJive
Contributing Member
Contributing Member
Posts: 25
Joined: Mon Aug 27, 2018 6:26 am

Re: Batch file to get rid of spaces in ROM filenames

Post by NoJive » Thu Jan 03, 2019 2:39 am

dee2eR wrote:
Tue Jan 01, 2019 2:05 pm
Thanks for posting that, great idea. It's probably also useful for images. With some tweaking it could be worth adding that as an option in the service menu (although could also be disastrous if it goes wrongly...)
No problem! It does work well...fixed my ROM issues for sure!

Post Reply