Reputation: 5681
I need to write to file list of folders and subfolders from a given folder. I use this command:
dir /s /b /o:n /a:d > folderlist.txt
Dotted characters are not present in the output file. Output of command contains also dotted characters when I check it in cmd
. I don't use PowerShell.
Upvotes: 0
Views: 292
Reputation: 6183
First of all, the characters you need are not avaliable by default, please run: chcp 65001
- this will change the encoding to UTF-8.
Then you can run your command: dir /s /b /o:n /a:d > folderlist.txt
.
If you need to view the output in the cmd. Please change the default font to Lucida Console
.
Before OP clarified what he was after, i managed to come up with this:
Assuming your filesystem is of reasonable size, you can use the tree
command, which produces a indented tree-structure for you. You can tell it to use ASCII characters also with the /A
flag. Try it out!
cmd: tree /A ["directory path"] > "DRIVE_LETTER:\PATH_TO_EXPORT\tree.txt"
/A
- ASCII characters instead of extended characters.
/F
- Display the names of the files in each folder.
Note that the "directory path"
is optional, but it seems like you want to use it in this case (insert the path of your starting-folder).
If you cant use tree
(for simple output reasons) - you can use:
DIR YOUR_DRIVE_LETTER:\ /B /S > "DRIVE_LETTER:\PATH_TO_EXPORT\tree.txt"
/B
-flag = full path instead of relative path.
powershell: Get-ChildItem | tree > "DRIVE_LETTER:\PATH_TO_EXPORT\tree.txt"
Upvotes: 1
Reputation: 1741
If tree
solution is not suitable for you then you could run cmd with unicode support cmd /u
. Or change codepage to UTF inside of batch file with chcp 65001
.
Upvotes: 0