Here you can do it in batch mode (if you're interested). The big limitation is that if you have file names with a symbol of more than one percent, this will not work, because the shell expands it to a variable. I do not know how to fix this.
It is launched from any directory in which the script is located, and works recursively on all subdirectories.
@echo off setlocal enabledelayedexpansion for /f "usebackq delims=" %%N in (`dir /s /b`) do ( set var=%%~nN set var=!var:^&= ! set var=!var:%%= ! if not "!var!"=="%%~nN" ( if not exist "%%~dpN!var!%%~xN" ( echo "%%N" --^> "!var!%%~xN" ren "%%N" "!var!%%~xN" ) else ( echo File "!var!%%~xN" ^(from %%N^) already exists. ) ) )
For example, prints the output as follows:
C:\batch\schar>schar "C:\batch\schar\Test%doc.doc" --> "Test doc.doc" "C:\batch\schar\Test%doc.pdf" --> "Test doc.pdf" File "Test doc.pdf" (from C:\batch\schar\Test&doc.pdf) already exists. "C:\batch\schar\subdir\FILE%here" --> "FILE here"
indiv
source share