Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何从文件名中的字符中删除西班牙语重音?_Windows_File_Batch File_Rename - Fatal编程技术网

Windows 如何从文件名中的字符中删除西班牙语重音?

Windows 如何从文件名中的字符中删除西班牙语重音?,windows,file,batch-file,rename,Windows,File,Batch File,Rename,第一种情况: 我创建了一个重命名文本文件ren.bat。该文件的内容如下: ren "a*.pdf" "T*.pdf" 当我运行ren.bat文件时,该命令会重命名文件夹中的所有PDF文件,但只有第一个字母a不会贯穿整个文件名,而是替换字母a 谁能告诉我怎么了 第二种情况: 当我运行命令时: ren "ã*.pdf" "a*.pdf" 该命令不会重命名第一个字母 谁能告诉我怎么了 我找到了一个有效的代码。但是我不知道如何调整它,这样我就可以读取文件夹中的所有文件,而不必识别有问题的文件名。您

第一种情况:

我创建了一个重命名文本文件
ren.bat
。该文件的内容如下:

ren "a*.pdf" "T*.pdf"
当我运行
ren.bat
文件时,该命令会重命名文件夹中的所有PDF文件,但只有第一个字母
a
不会贯穿整个文件名,而是替换字母
a

谁能告诉我怎么了

第二种情况:

当我运行命令时:

ren "ã*.pdf" "a*.pdf"
该命令不会重命名第一个字母

谁能告诉我怎么了

我找到了一个有效的代码。但是我不知道如何调整它,这样我就可以读取文件夹中的所有文件,而不必识别有问题的文件名。您试图创建的是一个
.bat
文件,该文件通过删除缩进文件所用名称的重音符号来重命名文件。请注意,此代码必须指定文件名:

For /F "Tokens=2 Delims=:" %%I In ('Chcp ') Do Set /A _CurCP=%%I
Chcp 1252
ren "méxico.txt" "mexico.txt"
Chcp %_CurCP%
我需要它是那样的,但那不起作用:

ren "áéí*.txt" "aei*.txt"

首先,您应该了解可以使用不同的代码值保存字符。这就是所谓的

有些字符编码只使用一个8位字节来表示一个最多2^8=256个字符的字符。但是有很多字符,远远超过256个。出于这个原因,有很多。代码页定义哪个字节值表示哪个字符

Windows根据配置的国家/地区为图形用户界面(GUI)和GUI应用程序(如Windows记事本)以及控制台应用程序(如Windows命令处理器)设置代码页

对于西欧国家,代码页默认设置为每个字符仅一个字节的文本编码。西欧国家控制台上使用的代码页与打开命令提示符窗口并在不带任何参数的情况下运行命令
chcp
时的代码页相同
chcp
是更改代码页的缩写

成立的目的是为了停止定义越来越多的代码页,请参见该联合会的介绍–通用代码,用于对世界上大多数书写系统中表达的文本进行一致的编码、表示和处理。该联盟还定义了如何编码字符和符号的标准。最受欢迎的是和


其次,通过了解字符编码,让我们来看看像
ã
é
这样的字符

Windows记事本在保存批处理文件时使用Windows-1252,在另存为对话框窗口中使用ANSI进行选项编码,并将西班牙配置为国家/地区。ANSI在这里的意思是使用代码页的每个字符一个字节,而不是标准化许多代码页

但是Windows命令处理器
cmd.exe
解释批处理文件中的行时使用代码页OEM 850

可以为每个正在运行的进程分别在代码页中定义字符编码。您可能已经在Windows任务栏上看到了两个字母的语言缩写,可用于更改当前活动应用程序的语言,即用于非Unicode字符编码的代码页

字符
ã
在代码页Windows-1252中具有十进制代码值227,但在代码页OEM 850中具有代码值198。字符
é
在代码页Windows-1252中为十进制代码值233,但在代码页OEM 850中为代码值130

那么如何解决不同字符编码的问题呢

一种解决方案是使用代码页OEM 850编写批处理文件。使用Windows记事本,这并不容易。其他文本编辑器更好地支持这一点,如UltraEdit,我已将其配置为使用Windows为控制台应用程序定义的OEM代码页自动编辑*.bat和*.cmd文件,而所有其他非Unicode编码的文本文件使用Windows为GUI应用程序定义的Windows代码页

另一种解决方案是使用代码页Windows-1252写入批处理文件,并在执行其他命令行之前,先使用命令
chcp 1252
将批处理文件执行时的代码页更改为此代码页。对于大多数用户来说,这是一个更简单的解决方案


那么使用字符串替换的批处理代码呢

@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
for /F "eol=| delims=" %%I in ('dir * /A-D-H /B 2^>nul') do call :RenameFile "%%I"
endlocal
goto :EOF

@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
for /F "eol=| delims=" %%I in ('dir * /A-D-H /B 2^>nul') do call :RenameFile "%%I"
endlocal
goto :EOF

:RenameFile
set "FileName=%~1"
set "FileName=%FileName:Š=S%"
set "FileName=%FileName:Ž=Z%"
set "FileName=%FileName:š=s%"
set "FileName=%FileName:ž=z%"
set "FileName=%FileName:Ÿ=Y%"
set "FileName=%FileName:À=A%"
set "FileName=%FileName:Á=A%"
set "FileName=%FileName:Â=A%"
set "FileName=%FileName:Ã=A%"
set "FileName=%FileName:Ä=A%"
set "FileName=%FileName:Å=A%"
set "FileName=%FileName:È=E%"
set "FileName=%FileName:É=E%"
set "FileName=%FileName:Ê=E%"
set "FileName=%FileName:Ë=E%"
set "FileName=%FileName:Ì=I%"
set "FileName=%FileName:Í=I%"
set "FileName=%FileName:Î=I%"
set "FileName=%FileName:Ï=I%"
set "FileName=%FileName:Ñ=N%"
set "FileName=%FileName:Ò=O%"
set "FileName=%FileName:Ó=O%"
set "FileName=%FileName:Ô=O%"
set "FileName=%FileName:Õ=O%"
set "FileName=%FileName:Ö=O%"
set "FileName=%FileName:Ù=U%"
set "FileName=%FileName:Ú=U%"
set "FileName=%FileName:Û=U%"
set "FileName=%FileName:Ü=U%"
set "FileName=%FileName:Ý=Y%"
set "FileName=%FileName:à=a%"
set "FileName=%FileName:á=a%"
set "FileName=%FileName:â=a%"
set "FileName=%FileName:ã=a%"
set "FileName=%FileName:ä=a%"
set "FileName=%FileName:å=a%"
set "FileName=%FileName:è=e%"
set "FileName=%FileName:é=e%"
set "FileName=%FileName:ê=e%"
set "FileName=%FileName:ë=e%"
set "FileName=%FileName:ì=i%"
set "FileName=%FileName:í=i%"
set "FileName=%FileName:î=i%"
set "FileName=%FileName:ï=i%"
set "FileName=%FileName:ñ=n%"
set "FileName=%FileName:ò=o%"
set "FileName=%FileName:ó=o%"
set "FileName=%FileName:ô=o%"
set "FileName=%FileName:õ=o%"
set "FileName=%FileName:ö=o%"
set "FileName=%FileName:ù=u%"
set "FileName=%FileName:ú=u%"
set "FileName=%FileName:û=u%"
set "FileName=%FileName:ü=u%"
set "FileName=%FileName:ý=y%"
set "FileName=%FileName:ÿ=y%"

rem Is it necessary to rename the file?
if "%FileName%" == "%~1" goto :EOF

rem Is there already a file with new file name?
if exist "%FileName%" goto :EOF

echo Renaming "%~1" to "%FileName%"
ren "%~1" "%FileName%"
goto :EOF
看起来很有希望。但有一个问题。Windows命令处理器执行字符串替换,始终不区分大小写。这意味着在第一个字符串替换命令行上,
Š
š
都被
s
替换

但是下面的批处理文件使字符替换区分大小写

@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
for /F "eol=| delims=" %%I in ('dir * /A-D-H /B 2^>nul') do call :RenameFile "%%I"
endlocal
goto :EOF

:RenameFile
set "FileName=%~1"
set "NewName="
:NextChar
if not defined FileName goto CompareNames
set "Char=%FileName:~0,1%"
set "FileName=%FileName:~1%"
if "%Char%" == "Š" set "NewName=%NewName%S" & goto NextChar
if "%Char%" == "Ž" set "NewName=%NewName%Z" & goto NextChar
if "%Char%" == "š" set "NewName=%NewName%s" & goto NextChar
if "%Char%" == "ž" set "NewName=%NewName%z" & goto NextChar
if "%Char%" == "Ÿ" set "NewName=%NewName%Y" & goto NextChar
if "%Char%" == "À" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Á" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Â" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Ã" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Ä" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Å" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "È" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "É" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ê" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ë" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ì" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Í" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Î" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Ï" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Ñ" set "NewName=%NewName%N" & goto NextChar
if "%Char%" == "Ò" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ó" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ô" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Õ" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ö" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ù" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ú" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Û" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ü" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ý" set "NewName=%NewName%Y" & goto NextChar
if "%Char%" == "à" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "á" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "â" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "ã" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "ä" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "å" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "è" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "é" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ê" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ë" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ì" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "í" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "î" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "ï" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "ñ" set "NewName=%NewName%n" & goto NextChar
if "%Char%" == "ò" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ó" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ô" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "õ" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ö" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ù" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ú" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "û" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ü" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ý" set "NewName=%NewName%y" & goto NextChar
if "%Char%" == "ÿ" set "NewName=%NewName%y" & goto NextChar
set "NewName=%NewName%%Char%" & goto NextChar

:CompareNames
rem Is it necessary to rename the file?
if "%~1" == "%NewName%" goto :EOF

rem Is there already a file with new file name?
if exist "%NewName%" goto :EOF

echo Renaming "%~1" to "%NewName%"
ren "%~1" "%NewName%"
goto :EOF
与使用批处理文件使用Windows command processor执行此文件重命名任务相比,最好使用任何其他编程或脚本语言,因为如果文件名包含Unicode字符,且代码页Windows-1252中不提供代码值,则此任务的速度非常慢,而且仍然容易出错

批处理文件针对文件名中的每个字符运行,并使用命令IF进行大量区分大小写的字符串比较,这使得此解决方案对于当前目录中的许多文件名来说非常缓慢

当然,可以通过使用FOR循环来优化此代码,以减少命令行,但我认为这并不会大大减少执行所有区分大小写的文件重命名所需的时间


有五种解决方案可以在特定文件夹而不是当前目录上重命名文件

第一个解决方案:
使用命令CD将包含要重命名的文件的目录临时设置为当前目录:

@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
cd /D "C:\Temp\Folder with files to rename" 2>nul
if not errorlevel 1 for /F "eol=| delims=" %%I in ('dir * /A-D-H /B 2^>nul') do call :RenameFile "%%I"
endlocal
goto :EOF
@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
pushd "C:\Temp\Folder with files to rename" 2>nul
if not errorlevel 1 (
    for /F "eol=| delims=" %%I in ('dir * /A-D-H /B 2^>nul') do call :RenameFile "%%I"
    popd
)
endlocal
goto :EOF
与上面的代码相比,子程序
RenameFile
中没有任何更改

默认情况下,此解决方案不使用UNC路径,除非在Windows s版本中修改并使用了特殊注册表值
@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
set "FolderPath=C:\Temp\Folder with files to rename"
for /F "eol=| delims=" %%I in ('dir "%FolderPath%\*" /A-D-H /B 2^>nul') do call :RenameFile "%%I"
endlocal
goto :EOF

:RenameFile
set "FileName=%~1"
set "NewName="
:NextChar
if not defined FileName goto CompareNames
set "Char=%FileName:~0,1%"
set "FileName=%FileName:~1%"
if "%Char%" == "Š" set "NewName=%NewName%S" & goto NextChar
if "%Char%" == "Ž" set "NewName=%NewName%Z" & goto NextChar
if "%Char%" == "š" set "NewName=%NewName%s" & goto NextChar
if "%Char%" == "ž" set "NewName=%NewName%z" & goto NextChar
if "%Char%" == "Ÿ" set "NewName=%NewName%Y" & goto NextChar
if "%Char%" == "À" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Á" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Â" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Ã" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Ä" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Å" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "È" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "É" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ê" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ë" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ì" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Í" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Î" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Ï" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Ñ" set "NewName=%NewName%N" & goto NextChar
if "%Char%" == "Ò" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ó" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ô" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Õ" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ö" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ù" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ú" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Û" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ü" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ý" set "NewName=%NewName%Y" & goto NextChar
if "%Char%" == "à" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "á" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "â" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "ã" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "ä" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "å" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "è" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "é" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ê" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ë" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ì" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "í" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "î" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "ï" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "ñ" set "NewName=%NewName%n" & goto NextChar
if "%Char%" == "ò" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ó" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ô" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "õ" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ö" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ù" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ú" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "û" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ü" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ý" set "NewName=%NewName%y" & goto NextChar
if "%Char%" == "ÿ" set "NewName=%NewName%y" & goto NextChar
set "NewName=%NewName%%Char%" & goto NextChar

:CompareNames
rem Is it necessary to rename the file?
if "%~1" == "%NewName%" goto :EOF

rem Is there already a file with new file name?
if exist "%FolderPath%\%NewName%" goto :EOF

echo Renaming "%~1" to "%NewName%"
ren "%FolderPath%\%~1" "%NewName%"
goto :EOF
@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
set "FolderPath=C:\Temp\Folder with files to rename"
for /F "eol=| delims=" %%I in ('dir "%FolderPath%\*" /A-D-H /B 2^>nul') do call :RenameFile "%FolderPath%\%%I"
endlocal
goto :EOF

:RenameFile
set "FileName=%~nx1"
set "NewName="
:NextChar
if not defined FileName goto CompareNames
set "Char=%FileName:~0,1%"
set "FileName=%FileName:~1%"
if "%Char%" == "Š" set "NewName=%NewName%S" & goto NextChar
if "%Char%" == "Ž" set "NewName=%NewName%Z" & goto NextChar
if "%Char%" == "š" set "NewName=%NewName%s" & goto NextChar
if "%Char%" == "ž" set "NewName=%NewName%z" & goto NextChar
if "%Char%" == "Ÿ" set "NewName=%NewName%Y" & goto NextChar
if "%Char%" == "À" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Á" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Â" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Ã" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Ä" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "Å" set "NewName=%NewName%A" & goto NextChar
if "%Char%" == "È" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "É" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ê" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ë" set "NewName=%NewName%E" & goto NextChar
if "%Char%" == "Ì" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Í" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Î" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Ï" set "NewName=%NewName%I" & goto NextChar
if "%Char%" == "Ñ" set "NewName=%NewName%N" & goto NextChar
if "%Char%" == "Ò" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ó" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ô" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Õ" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ö" set "NewName=%NewName%O" & goto NextChar
if "%Char%" == "Ù" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ú" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Û" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ü" set "NewName=%NewName%U" & goto NextChar
if "%Char%" == "Ý" set "NewName=%NewName%Y" & goto NextChar
if "%Char%" == "à" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "á" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "â" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "ã" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "ä" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "å" set "NewName=%NewName%a" & goto NextChar
if "%Char%" == "è" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "é" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ê" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ë" set "NewName=%NewName%e" & goto NextChar
if "%Char%" == "ì" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "í" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "î" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "ï" set "NewName=%NewName%i" & goto NextChar
if "%Char%" == "ñ" set "NewName=%NewName%n" & goto NextChar
if "%Char%" == "ò" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ó" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ô" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "õ" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ö" set "NewName=%NewName%o" & goto NextChar
if "%Char%" == "ù" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ú" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "û" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ü" set "NewName=%NewName%u" & goto NextChar
if "%Char%" == "ý" set "NewName=%NewName%y" & goto NextChar
if "%Char%" == "ÿ" set "NewName=%NewName%y" & goto NextChar
set "NewName=%NewName%%Char%" & goto NextChar

:CompareNames
rem Is it necessary to rename the file?
if "%~nx1" == "%NewName%" goto :EOF

rem Is there already a file with new file name?
if exist "%~dp1%NewName%" goto :EOF

echo Renaming "%~nx1" to "%NewName%"
ren "%~1" "%NewName%"
goto :EOF
@echo off
setlocal EnableExtensions DisableDelayedExpansion
%SystemRoot%\System32\chcp.com 1252 >nul
for /F "eol=| delims=" %%I in ('dir "C:\Temp\Folder with files to rename\*" /A-D-H /B /S 2^>nul') do call :RenameFile "%%I"
endlocal
goto :EOF