Inquiridor
How Do I print a List of Folders within a Drive ?

Pergunta
-
In preparation for a mass migration to a new drive, I want to get a listing of
all the folders residing within each Drive.
Every combination of names (Folders, Directories, etc) all result in the same
thing. I get pointed to listing the Files in a Folder. Not what I want. I just
want a list of Folders, like you see when you click on a Drive Letter.
Why is such a simple task so difficult ??
Thank you,
Richard S.
Richard S.
Todas as Respostas
-
Hi Richard.
You can get such a list in PowerShell by using the Get-ChildItem cmdlet as in the below snippet
Get-ChildItem -Path C:\ -Recurse -Directory -Force -ErrorAction SilentlyContinue | Select-Object FullName > FoldersList.txt
In this example, the loop starts from the C: drive and save a list of all the folders and subfolders (with their full paths) into the file named "FoldersList.txt".
Bye.
Luigi Bruno
MCP, MOS, MTA, MCTS, MCSA, MCSE
- Editado Luigi BrunoMVP quarta-feira, 7 de agosto de 2019 15:37
-
-
To display the folder hierarchy, open File Explorer, navigate to the folder you wish to start at, hold down the Shift key, right-click or press and hold on the folder name and choose Open PowerShell window here.
Type tree |clip and press Enter. Open your word processor program (or Notepad) and paste (Ctrl+V) the list to it. You can now print it, edit it or save it.
-
It's not the data in a single folder I want, it's a list of all the Folders
on the drive.
As primitive as it sounds, I can get the results I need with the Print
Screen command, although it takes several pages to get what I need.
rs
Richard S.
-
Open a Command Prompt (as Admin if not admin)
Ensure you are at the root of your drive (ie: C:\ )
use this command:
dir /s /b /o:n /ad >c:\temp\myfolders.txt
Once done, open C\temp\Myfolders.txt (or whatever you wish to call it) and there you are.
-
-
Here I have reworded my original reply using a command prompt.
Open a cmd prompt at the location you wish to start at, e.g. C:, D: or folder C:\Windows. A listing of C: will take some time and will be very long, perhaps 50,000 folders.
Type tree |clip and press Enter, when it is finished, open your word processor program (or Notepad) and paste (Ctrl+V) the list to it. You can now print it, edit it or save it.
A command prompt will give a neater display/print out than PowerShell.
- Editado BurrWalnut quinta-feira, 8 de agosto de 2019 05:36
-
Opened PowerShell, cut and pasted the command in at the prompt,
and nothing happened ??
rs
Richard S.
The output of the command is saved into the "FoldersList.txt" file that is created in the folder where the PowerShell snippet has been executed from.
Let's rewrite the snippet this wayGet-ChildItem -Path C:\ -Recurse -Directory -Force -ErrorAction SilentlyContinue | Select-Object FullName > C:\FoldersList.txt
As you can see at the end, the file with the list of folders will be saved into the C:\ drive (you can change it to the location you prfere, of course) and it will looks someway like thisYou have to wait for the command to complete its execution before having the file ready for printing.
Bye.
Luigi Bruno
MCP, MOS, MTA, MCTS, MCSA, MCSE
- Editado Luigi BrunoMVP quinta-feira, 8 de agosto de 2019 05:41
- Sugerido como Resposta Teemo TangMicrosoft contingent staff, Moderator sexta-feira, 30 de agosto de 2019 08:09
-
That didn't work either.
rs
Richard S.
Did you try to execute the PowerShell snippet as per my last reply? Can you see the file named "FoldersList.txt" in the C:\ drive?
Bye.
Luigi Bruno
MCP, MOS, MTA, MCTS, MCSA, MCSE
- Editado Luigi BrunoMVP sexta-feira, 20 de setembro de 2019 19:35