我的目标是让“test.txt”文件使用“UTF-8”编码创建,而不是使用“ANSI”编码创建。我附上了整个批处理文件:
@echo off
cls
break > test.txt
pushd "C:\Users\MARKETING 1\Desktop\SHARED" || exit /B 1
for /D %%D in ("*") do (
rd /S /Q "%%~D"
)
for %%F in ("*") do (
if /I not "%%~nxF"=="FILES SAVED HERE WILL BE AUTOMATICALLY DELETED EVERY SATURDAY.txt" del "%%~F"
)
popd
start test.txt
echo %DATE% %TIME% >> test.txt
if %errorlevel% NEQ 1 Echo ERROR DETECTED>>test.txt
if %errorlevel% EQU 1 Echo No error detected>>test.txt
if %errorlevel% NEQ 1 (echo No errors found) ELSE (echo ERROR DETECTED)>>test.txt
if %errorlevel% EQU 1 echo No errors found || echo ERROR DETECTED>>test.txt
dir "C:\Users\MARKETING 1\Desktop\SHARED">>test.txt
应具有“UTF-8”编码的文件是名为“test.txt”的文件。
我放了一个批处理文件的字符串以便您更好地理解:
break > test.txt