Quantcast
Channel: Lambo's Blog
Viewing all articles
Browse latest Browse all 12

Enumerating files and folders to a specified folder depth

$
0
0

Using Powershell, i wanted to get a list of only folder names for a specified directory.  I didn’t want the entire sub-folder tree for all of the folders, only the ‘top level’ folders.

 

The command get-childitem \\foldername –recurse would give me all of the files and subfolders.

 

The command get-childitem \\foldername\*\* will give me the root folder, the first layer of subfolders, and the second layer of subfolders.

 

To list only folder names, use get-childitem \\foldername\*\* –directory

 

To output this to a csv file use get-childitem \\foldername\*\* –directory | export-csv c:\outputfilename.csv


Viewing all articles
Browse latest Browse all 12

Trending Articles