Export directory list to csv with command prompt

This one is mainly a note to self, but maybe someone will find it helpful. no exposition here!

I needed to get a list of all folders in a directory into an excel spreadsheet. let’s say the location was D:\shared\filesharename

  1. open command prompt
  2. Enter D: to switch to the d drive
  3. enter cd shared\filesharename to access the folder
  4. enter dir /b /ad > c:\temp\filesharenames_subfolders.csv
    • /b uses bare format, no heading or summary
    • /ad filters for only directories, as i don’t want files included
    • > exports it to the file specified
    • C:\temp\filesharenames_subfolders.csv is the file it is outputting to

I end up with list of the folders in this directory that can be copy pasted into excel easily!