In a 2010 site colelction I have a document library with a complicated structure and lots of subfolders that I want to move to a flat structure. How can I get a hierarchical list of all (sub-)folders and all files? Maybe with powershell (v1)?
2 Answers
You can use PowerShell to get this information
Function GetFiles($folder)
{
Write-Host $folder.Name
foreach($file in $folder.Files)
{
Write-Host $file.Name
}
foreach ($subFolder in $folder.SubFolders)
{
GetFiles($Subfolder)
}
}
$web = Get-SPWeb http://weburl
$list = $web.Lists["ListName"]
GetFiles($list.RootFolder)
I know this is old, but others might find this question when looking it up. I figured out a very easy way:
https://www.linkedin.com/pulse/how-export-sharepoint-document-library-excel-show-folder-cardonick