Following batch script and sample text file show that CMD
/Batch is capable to work with file names from UCS-2
Unicode subset providing that
(CJK Ideographs and Central European accented Latin letters are used in following examples, both explicitly used in a batch command and read from a saved list of such file names.)
Note that the weird first line in bat
script (@foo.bar >NUL 2>&1
) is there as cmd
is UTF-8
aware but isn't BOM aware (cf byte order mark):
- if script is saved without BOM then this line would be performed with no effect while
- if script is saved with BOM then this line would be listed prefixed with some character(s), see

in the following output.
Note that the first line in txt
file list is empty for the same reason (cmd
isn't BOM aware) so for /F
loop would ignore this empty line if BOM is not present otherwise an attempt to do something with such file raises File Not Found
error (this message could be suppressed using 2>NUL
).
42030220.bat
script:
@foo.bar >NUL 2>&1
@echo OFF
SETLOCAL EnableExtensions DisableDelayedExpansion
chcp 65001
echo next command: for /F "usebackq delims=" %%G …
for /F "usebackq delims=" %%G in ("D:\bat\files\unASCII\42030220.txt") do (
dir /B /S "%%~G"
REM
REM use `del /S "%%~G"` instead of `dir /B /S "%%~G"`
)
echo next command: dir /B /S /A:-D "D:\bat\Unusual Names\CJK\中文(繁體)\*"
dir /B /S /A:-D "D:\bat\Unusual Names\CJK\中文(繁體)\*"
42030220.txt
file list (note leading empty line):
二月.mp3
ěščřžýáíé.txt
装备女印度舞娘时装上衣.rtf
Output:
d:\bat> d:\bat\SO\42030220.bat
d:\bat> @foo.bar 1>NUL 2>&1
Active code page: 65001
next command: for /F "usebackq delims=" %G …
File Not Found
d:\bat\Unusual Names\CJK\中文(繁體)\二月.mp3
d:\bat\UnASCII Names\ěščřžýáíé.txt
d:\bat\Unusual Names\CJK\中文(繁體)\装备女印度舞娘时装上衣.rtf
next command: dir /B /S /A:-D "D:\bat\Unusual Names\CJK\中文(繁體)\*"
D:\bat\Unusual Names\CJK\中文(繁體)\chinese traditional.txt
D:\bat\Unusual Names\CJK\中文(繁體)\二月.mp3
D:\bat\Unusual Names\CJK\中文(繁體)\装备女印度舞娘时装上衣.rtf
d:\bat>