batch remove periods from files

I had a user that had a folder of files that had a lot of .’s in the names.  As an example:
I.like.kayaking.txt
This.is.a.sample.file.txt

They needed all of the .’s replaced with a space.  Here is the contents of the batch file that I created to fix the issue:


@echo off
 setlocal enableextensions disabledelayedexpansion

for %%a in (*) do (
 set "filename=%%~na"
 setlocal enabledelayedexpansion
 for %%f in ("!filename:.= !") do (
 endlocal
 ren "%%~fa" "%%~f%%~xa"
 )
 )

All the user has to do is copy the .bat file into the directory that has the problem files and then run the .bat file.

This is a slightly modified version of the script found at: https://stackoverflow.com/questions/28558996/batch-file-for-replacing-dots-with-spaces-in-file-names

Leave a Reply

Your email address will not be published. Required fields are marked *