Saving 'tree /f /a" results to a textfile with unicode support

前端 未结 12 1693
清歌不尽
清歌不尽 2021-02-02 07:10

I\'m trying to use the tree command in a windows commandline to generate a text file listing the contents of a directory but when I pipe the output the unicode characters get st

12条回答
  •  囚心锁ツ
    2021-02-02 08:07

    This will save the results as ASCII (American Standard Code for Information Interchange) on your desktop, ASCII\ANSI doesn't recognize every international or extended character:

    tree /f > ascii.txt
    

    This will convert your ASCII text to Unicode (/c must precede actual command):

    cmd /u /c type ascii.txt > unicode.txt
    

    So why not just think of the ascii file as a temporary file and delete it?

    del ascii.txt
    

    If you must put all in one line you could use:

    tree /f > ascii.txt & cmd.exe /u /c type ascii.txt > unicode.txt & del ascii.txt
    

提交回复
热议问题