I've found the following post: Batch File to replace underscores with spaces in a filename
This seems to work but when you drag a file onto the batch file, it processes all of the files in the folder.
@echo off
setlocal enabledelayedexpansion
for %%a in (*_*) do (
set file=%%a
ren "!file!" "!file:_= !"
)
Is there a way to edit this so I can just drag just the file I want to rename onto the batch file and just have that file renamed?
I also found this link that works great for just renaming one file, but it does the opposite of what I'm trying to do: Renaming files with spaces and dots in the filename
@ECHO OFF &setlocal
FOR %%f IN (%*) DO (
set "oldname=%%~ff"
set "oldfname=%%~nf"
set "extension=%%~xf"
setlocal enabledelayedexpansion
set "filename=!oldfname:.=_!"
set "filename=!filename: =_!"
if not "!filename!"=="!oldfname!" RENAME "!oldname!" "!filename!!extension!"
endlocal
)
Thank you!
-Thom K.