This is the batch file I wrote to rename files. The problem I get is that if the file name includes one of the following symbol, the script does not work. %
&
=
@echo off
SETLOCAL
set file="C:\Users\Desktop\newdocument.txt"
SET file1=%file: =%
FOR /f %%i IN ("%file1%") DO (
set fileextension=%%~xi
)
REN %file% "newname%fileextension%"
The following example shows you how to work the character substitution.
Please just open cmd instead of clicking on batch-file, navigate in the directory where is your script and run the script.
Note I added an instance
pause
.Output:
Edit: I updated the example with the characters that you mentioned.