在批处理文件中的文本/ CSV文件转换为UTF-8格式
在这里WMIC命令给被写入到一个临时文件的输出,我编写一个批处理文件
I am coding a batch file where WMIC command gives an output which is written to a temp file
WMIC /node:%%A Volume get systemname,caption,freespace,capacity > temp.txt
临时文件生成,但它的编码是的 UCS-2的Little Endian。
所以,当我试图使用循环读取文本文件,
So, when I am trying to read the text file using for loop,
for /f "tokens=1" %%B in (temp.txt) do (
echo %%B
)
这多年平均值显示任何输出,因为它的编码格式。
This doesnot displays any output because of its encoding format.
在我这个转换的 TEMP.TXT 以UTF-8 / ANSI格式的for循环读取临时文件。
Once I convert this Temp.txt to UTF-8/ANSI format the for loop reads the Temp file.
我可以知道我怎么能得到WMIC命令的输出中的 UTF-8 / ANSI 或如果不是我怎么可以转换的 UCS-2的Little Endian 为 UTF-8 / ANSI
Can I know how can I get the output of WMIC command in UTF-8/ANSI or if not how can I convert UCS-2 Little Endian to UTF-8/ANSI
问候
您可以过滤WMIC的输出转换文件
You can filter the output of the wmic to convert the file
WMIC /node:%%A Volume get systemname,caption,freespace,capacity | find /v "" > temp.txt
或者可以将文件转换与键入
命令
WMIC ..... > temp1.txt
type temp1.txt > temp.txt
或者,你可以直接检索在为
循环的信息
for /f "tokens=1-4 delims=," %%a in (
'wmic /node:%%A Volume get systemname^,caption^,freespace^,capacity'
) do echo %%a %%b %%c %%d