Usually the best way to download all documents from a SharePoint Document library or any specific folder from document library is to sync the folder using OneDrive client. It will sync all the content and it will also be used uploaded bulk content on a SharePoint document library.
Download Documents using OneDrive Sync client
Below are the steps to upload data in bulk:
- Go to the document library or folder which you want to download.
- Click on the sync button, it will open a dialog to select the folder location on local machine.
- Click on the Open Microsoft OneDrive button shown in the above screenshot. Make sure popups are not blocked on the browser. You might need to download the sync client if it’s not installed on your machine.
- If you haven’t configured OneDrive client on your local machine then it will show you a dialog to install to sign in to your OneDrive first. You can also see the icon of OneDrive sync client in system tray.
- Complete the wizard and at the end you will see the option to open my OneDrive folder. Click on that and it will show you all the files on your local drive which were synced. You can also see in the below screenshot.
- This process will allow you to download all your documents from a document library. You can also upload documents from your machine directly to that folder and those will automatically sync on SharePoint Online.
- If you only want to download the files and do not want to keep syncing then right click on the Onedrive client icon on system try and click on settings.
- Click on Stop Sync button to stop from syncing that document library
This is the easiest way to download document from SharePoint document library or from a folder.
Download SharePoint Document library Documents using PowerShell
There is another alternate way to download all files from a SharePoint document library using PowerSheel. I have shared a PowerShell script in an old post to download all documents from a user’s OneDrive, we can use the same pnp Powershell to download documents from a document library.
###########################################################################
#Author: Adnan Amin
#blog: Https://mstechtalk.com
#Downloading files from OneDrive to local machine
###########################################################################
#################### Parameters ###########################################
$webUrl = "https://mstalk.sharepoint.com/Documents";
$listUrl = "Documents";
$destination = "D:\DownloadDocs"
###########################################################################
#Connect-PnPOnline -Url $webUrl
Connect-PnPOnline -Url $webUrl -UseWebLogin;
$web = Get-PnPWeb
$list = Get-PNPList -Identity $listUrl
function ProcessFolder($folderUrl, $destinationFolder) {
$folder = Get-PnPFolder -RelativeUrl $folderUrl
$tempfiles = Get-PnPProperty -ClientObject $folder -Property Files
if (!(Test-Path -path $destinationfolder)) {
$dest = New-Item $destinationfolder -type directory
}
$total = $folder.Files.Count
For ($i = 0; $i -lt $total; $i++) {
$file = $folder.Files[$i]
Write-Host "Copying file " $file.Name " at " $destinationfolder
Get-PnPFile -ServerRelativeUrl $file.ServerRelativeUrl -Path $destinationfolder -FileName $file.Name -AsFile
}
}
function ProcessSubFolders($folders, $currentPath) {
foreach ($folder in $folders) {
$tempurls = Get-PnPProperty -ClientObject $folder -Property ServerRelativeUrl
#Avoid Forms folders
if ($folder.Name -ne "Forms") {
$targetFolder = $currentPath +"\"+ $folder.Name;
ProcessFolder $folder.ServerRelativeUrl.Substring($web.ServerRelativeUrl.Length) $targetFolder
$tempfolders = Get-PnPProperty -ClientObject $folder -Property Folders
write-host "Processing folder: " $folder.Name " .. at " $currentPath
ProcessSubFolders $tempfolders $targetFolder
}
}
}
ProcessFolder $listUrl $destination + "\"
#Write-Host "listUrl: " $listUrl
#Download files in folders
$tempfolders = Get-PnPProperty -ClientObject $list.RootFolder -Property Folders
Write-Host "tempfolders: " $tempfolders
ProcessSubFolders $tempfolders $destination + "\"
The document download/sync process will take time as it depends on the number of documents in that folder.
2 Comments