dir/b > files.txt
I guess it has to be done in PowerShell to preserve unicode signs.
In PSH dir
(which aliases Get-ChildItem
) gives you objects (as noted in another answer), so you need to select what properties you want. Either with Select-Object
(alias select
) to create custom objects with a subset of the original object's properties (or additional properties can be added).
However in this can doing it at the format stage is probably simplest
dir | ft Name -HideTableHeaders | Out-File files.txt
(ft
is format-table
.)
If you want a different character encoding in files.txt
(out-file
will use UTF-16 by default) use the -encoding
flag, you can also append:
dir | ft Name -HideTableHeaders | Out-File -append -encoding UTF8 files.txt