I use the following commands on PowerShell to create a list of all files and subfolders within a specific directory:
get-childitem -path c:\users\username\desktop\test -recurse | select name
So assuming I have a folder called "test" on my desktop and within this folder I have three files and one subfolder, which itself contains further files and subfolders and so on, I do get something like this as an output:
subfolder 1 of "test"
file 1 in "test"
file 2 in "test"
file 3 in "test"
subfolder a of "subfolder 1"
file 1 in subfolder 1
file 2 in subfolder 1
file 3 in subfolder 1
file 1 in subfolder a
file 2 in subfolder a
file 3 in subfolder a
So this is nice but I would like to get another kind of output, something looking like this:
+ c:\users\username\desktop\test
| - file 1 in "test"
| - file 2 in "test"
| - file 3 in "test"
|--+ subfolder 1 of "test"
| | - file 1 in subfolder 1
| | - file 2 in subfolder 1
| | - file 3 in subfolder 1
| |--+ subfolder a of "subfolder 1"
| | | - file 1 in subfolder a
| | | - file 2 in subfolder a
| | | - file 3 in subfolder a
|--+ subfolder 2 of "test"
| | -
| | .
| . .
. .
.
Is it possible (and if yes - how then?) to get an output looking like this?
I know there was a dos command called "tree" back then but it cannot work with the output of get-childitem in PowerShell due to its limitations. Is there some kind of equivalent command in PowerShell or can I do this with the get-childitem command and its switches / additions / ... ?
Sorry for my bad English. And: Sorry, I am a total beginner on PowerShell.
The old "Tree" you're used to from cmd is an application in your system32 folder rather than some hard-coded cmd functionality.
So you can still run it from powershell as usual.
e.g.
Robocopy and some other well known applications work the same way.
Errors in external programs can be captured in $LastExitCode rather than the usual $Error. What those codes mean will vary depending on the program.