equivalent of (dir/b > files.txt) in PowerShell

后端 未结 6 1164
借酒劲吻你
借酒劲吻你 2021-02-05 05:04
dir/b > files.txt

I guess it has to be done in PowerShell to preserve unicode signs.

6条回答
  •  执笔经年
    2021-02-05 05:39

    Get-ChildItem | Select-Object -ExpandProperty Name > files.txt
    

    or shorter:

    ls | % Name > files.txt
    

    However, you can easily do the same in cmd:

    cmd /u /c "dir /b > files.txt"
    

    The /u switch tells cmd to write things redirected into files as Unicode.

提交回复
热议问题