This is a batch file question regarding the usage of sed v407 from the UnxUtils.
I do have some files in some directories that contain unicode chars.
Goal is to create a renaming script that does some substitutions to the filenames.
As usual, Dir /B /S /A:-D "DirPath"|sed "DoSomething" >"OutFile" produces an ansi file.
Unicode file or directory names cannot be displayed and become "?".
This one works to produce a UTF16LE file containing dirs/files with unicode chars:
@ECHO OFF
:: change codepage
chcp 1252>Nul
:: create a file with a byte order mark [UTF16LE]
ECHO ÿþ>"Dir16LE.txt"
:: cmd.exe /Unicode /ExecuteCmd'sAndExit; redirect dir results to 'Dir16LE.txt'
CMD /U /C DIR /B /S /A:-D "DirPath" >> "Dir16LE.txt"
ECHO End Of File&PAUSE>NUL&EXIT
Unfortunately sed seems not to be able to process a UTF16/32 file without hardcore coding.
Processing a UTF8 file is possible.
I'm in need to produce a UTF8 file containing dirs/files with unicode chars.
This does not work:
@ECHO OFF
chcp 1252>Nul
:: create byte order mark to point to a UTF8 file explicitly
ECHO >"Dir8.txt"
CMD /U /C DIR /B /S /A:-D "DirPath" >> "Dir8.txt"
:: also DIR /B /S /A:-D "DirPath" >> "Dir8.txt" does not work
ECHO End Of File&PAUSE>NUL&EXIT
I also tried suggestions from Rob van der Woude and created some "header files" instead of Echoing the BOM's.
http://www.robvanderwoude.com/type.php
No luck so far.
Does anybody know a solution?
Thanks in advance for any reply