@echo off
cd /d "D:\Path\To\Your\Files.ogg"
for /f tokens^=1*delims^=^%% %%i in =;('
"%WinDir%\System32\where.exe" .:*^%%*.ogg
');= do rename "%%~fi%%%%~j" "ZXS 40%%%%~j"
This for /f
loop command lists .ogg
files that contain the %
character in their names. It defines the file name in two parts: the portion before the %
and the portion after it. To handle the %
correctly in the command, an extra %
is added as an escape for the %
itself, while the initial %
is escaped using ^
. This prevents the command interpreter from misinterpreting the double %%
as a reference to a variable with no value (null
). The original command would fail to rename these files because it doesn’t properly account for the escaping required when handling the %
character in file names.
But note that @
does not interfere in any way with the rename
command via the command line and/or the batch file.