I am very new to batch scripting.
There are solutions regarding this for linux and macos, but I need it for windows.
I have the following, which only works on special characters !@#$%^&*~ etc. basically the ones you can see on your keyboard. But I need to remove special characters like  and °. The following scripts do not work on those two specific characters. , a script I can run via cmd. There is this but it is not winows7 cmd compatible.
@echo off &setlocal
cd /d c:\users\data
for /f "delims=" %%a in ('dir /b /a-d *#*.txt') do (
set "fname=%%~a"
setlocal enabledelayedexpansion
set "nname=!fname:#=!"
ren "!fname!" "!nname!"
endlocal
)
And the following which can remove spaces in file names only
@echo off
setlocal disableDelayedExpansion
if /i "%~1"=="/R" (
set "forOption=%~1 %2"
set "inPath="
) else (
set "forOption="
if "%~1" neq "" (set "inPath=%~1\") else set "inPath="
)
for %forOption% %%F in ("%inPath%* *") do (
if /i "%~f0" neq "%%~fF" (
set "folder=%%~dpF"
set "file=%%~nxF"
setlocal enableDelayedExpansion
echo ren "!folder!!file!" "!file: =!"
ren "!folder!!file!" "!file: =!"
endlocal
)
)