This may not be exactly what you're looking for, but it might be enough to point you in the right direction.
You can use the Send an HTTP request to SharePoint action to get all the folders in a list or library. Set these property values:
Uri: _api/Web/Lists/GetByTitle('[List Name]')/Items?$select=*,FileDirRef&$filter=FSObjType eq 1
Headers: { "Accept": "application/json;odata=nometadata" }
Replace [List Name] with the name of your list or library.
The FileDirRef
field in the select is the server relative URL for the folder. The FSObjType eq 1
filter tell SharePoint you only want folders.
You can then use a Select action to extract the information you want from the response from the Send an HTTP request to SharePoint action.
Use the following expressions:
From: body('Send_an_HTTP_request_to_SharePoint')['value']
Map - Title: item()['Title']
Map - ServerRelativeUrl: item()['FileDirRef']
The output from the Select action should be an array that looks something like the JSON you see below. You could use this information to populate the CSV file.
[
{
"Title": "Folder 1",
"ServerRelativeUrl": "/sites/demo3/Lists/Folder Test"
},
{
"Title": "Folder 2",
"ServerRelativeUrl": "/sites/demo3/Lists/Folder Test"
},
{
"Title": "Folder 11",
"ServerRelativeUrl": "/sites/demo3/Lists/Folder Test/Folder 1"
},
{
"Title": "Folder 12",
"ServerRelativeUrl": "/sites/demo3/Lists/Folder Test/Folder 1"
},
{
"Title": "Folder 121",
"ServerRelativeUrl": "/sites/demo3/Lists/Folder Test/Folder 1/Folder 12"
}
]
I hope this helps.