TXT文件如何批量修改编码

2024-12-18 23:08:55
推荐回答(2个)
回答1:

@echo off&color a
title TXT文本ANSI转UNICODE -by 314ccp-
set/p.=请将目录拖放此处:
cls & cd /d "%.%"
for /r %%a in (*.txt)do (
cmd /u /c "type "%%a">unicode.tmp"
copy unicode.tmp "%%a">nul
del unicode.tmp /q
)
echo 全部转换完成,可用WORD选Unicode验证了!
echo.
echo 按任意键打开目录!
pause>nul
start "" "%cd%"

打开批处理后将你要处理的目录拖放到光标处后回车!

回答2:

Const ForReading = 1
Const ForWriting = 2

strFolder = "e:\temp\temp"
oFolder = "e:\temp\new\"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")
Set objFolder = objFSO.GetFolder(strFolder)
objFSO.CreateFolder(oFolder)
Set colFiles = objFolder.Files

For Each strFile in colFiles
Set objFile = objFSO.OpenTextFile(strFile,ForReading,TristateTrue)
colLines = objFile.ReadAll
objFile.Close

Set objFile = objFSO.CreateTextFile(oFolder & strFile.Name,,True)
objFile.Write colLines
objFile.Close
Next

Set objFSO = Nothing
Set WshShell = Nothing

代码更新,请实际路径调整。