# 方法1.bat- @echo off
- cd /d "%~dp0"
- set "OldFile=1.txt"
- set "NewFile=2.txt"
- >"%temp%\BOM.tmp" echo 77u/
- certutil -decode -f "%temp%\BOM.tmp" "%NewFile%" >nul
- >>"%NewFile%" type "%OldFile%"
复制代码 # 方法2.bat- @echo off
- cd /d "%~dp0"
- set "OldFile=1.txt"
- set "NewFile=2.txt"
- powershell "[System.IO.File]::WriteAllBytes('%NewFile%',[byte[]](239,187,191)+[System.IO.File]::ReadAllBytes('%OldFile%'))"
复制代码 # 方法3.bat
http://bcn.bathome.net/s/tool/index.html?key=sed- @echo off
- cd /d "%~dp0"
- set "OldFile=1.txt"
- set "NewFile=2.txt"
- sed.exe "1s/^/\xEF\xBB\xBF/" "%OldFile%" > "%NewFile%"
复制代码
|