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

Soru
-
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.
Tüm Yanıtlar
-
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
- Düzenleyen Luigi BrunoMVP 7 Ağustos 2019 Çarşamba 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.
-
-
-
-
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.
- Düzenleyen BurrWalnut 8 Ağustos 2019 Perşembe 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
- Düzenleyen Luigi BrunoMVP 8 Ağustos 2019 Perşembe 05:41
- Yanıt Olarak Öneren Teemo TangMicrosoft contingent staff, Moderator 30 Ağustos 2019 Cuma 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
- Düzenleyen Luigi BrunoMVP 20 Eylül 2019 Cuma 19:35