Wednesday, 15 May 2013

encoding - Converting text/csv files to UTF-8 format in batch file -



encoding - Converting text/csv files to UTF-8 format in batch file -

i coding batch file wmic command gives output written temp file

wmic /node:%%a volume systemname,caption,freespace,capacity > temp.txt

temp file generated encoding ucs-2 little endian.

so, when trying read text file using loop,

for /f "tokens=1" %%b in (temp.txt) ( echo %%b )

this doesnot displays output because of encoding format.

once convert temp.txt utf-8/ansi format loop reads temp file.

can know how can output of wmic command in utf-8/ansi or if not how can convert ucs-2 little endian utf-8/ansi

regards

you can filter output of wmic convert file

wmic /node:%%a volume systemname,caption,freespace,capacity | find /v "" > temp.txt

or can convert file type command

wmic ..... > temp1.txt type temp1.txt > temp.txt

or can straight retrieve info in for loop

for /f "tokens=1-4 delims=," %%a in ( 'wmic /node:%%a volume systemname^,caption^,freespace^,capacity' ) echo %%a %%b %%c %%d

batch-file encoding utf-8 cmd

No comments:

Post a Comment