I wanted to automate the creation of a directory tree file in Windows 10.
In PowerShell, I executed the following commands:
cd C:\TreeTest tree /f > .\TreeStructure.txt
The output was a pretty UTF-8 file:
Now I wanted to do the same thing in a batch file:
@echo off cd C:\TreeTest tree /f > .\TreeStructure.txt
But the output from the batch file execution had the encoding screwed up:
Why is the encoding of the PowerShell output different from the output of the batch file?
I know that I can get an ASCII output by adding /a to the tree command, but I would prefer the pretty UTF-8 output to be saved to my tree file.
I tried changing the codepage by adding "chcp 65001" to my batch file, but it didn't change the file output.