How to extract folder structure to excel?

Hi,

Could you advise on how can I get the folder and file names with multiple levels into excel?

Folder & File Structure:
Lvl1Folder

  • Lvl2File.txt
  • Lvl2File.pdf
  • Lvl2Folder
    • Lvl3Files.txt
    • Lvl3Folder
      • Lvl4Files.pdf
      • Lvl4Folder

Excel to show it as:

Lvl1Folder Lvl2Folder Lvl3Folder Lvl4Files.pdf
Lvl1Folder Lvl2Folder Lvl3Files.txt
Lvl1Folder Lvl2File.txt
Lvl1Folder Lvl2File.pdf

I tried the following:

  1. Create data table
  2. for each and use Directory.GetFileSystemEntries to get folder and file name

Any advice how should i go about this? Thanks.

Hi @emily,
You can use powershell script:
Tree <folder path> /F | Out-String so it will draw you the full tree path for mentioned path and then pass this as a string to excel.

Example:
image