如何从SharePoint文件夹批量导出文件路径以批量添加Excel超链接?
Got it, let's tackle this problem—no more manual copy-pasting 200+ paths! Here are three reliable methods to bulk export SharePoint file/folder paths, which you can then use to quickly add hyperlinks in Excel.
This method gives you full control over what data you export, and works great for large folders.
- First, install the SharePoint Online Management Shell (you can grab it from the Microsoft Download Center if you don’t have it already).
- Open PowerShell as an administrator, then connect to your SharePoint site:
Connect-SPOService -Url https://yourtenant.sharepoint.com/sites/yoursite - Run this script to export file details (including full URLs) to a CSV file (easy to import into Excel later):
# Replace these placeholders with your actual SharePoint info $siteUrl = "https://yourtenant.sharepoint.com/sites/yoursite" $folderServerRelativePath = "/sites/yoursite/YourLibrary/TargetFolder" $outputCsvPath = "C:\YourLocalFolder\SharePointFilePaths.csv" # Set up SharePoint client context $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $credentials = Get-SPOCredentials $context.Credentials = $credentials # Get target folder and its files $folder = $context.Web.GetFolderByServerRelativeUrl($folderServerRelativePath) $files = $folder.Files $context.Load($files) $context.ExecuteQuery() # Collect file data $exportData = @() foreach ($file in $files) { $exportData += [PSCustomObject]@{ FileName = $file.Name FullUrl = $siteUrl + $file.ServerRelativeUrl ServerRelativePath = $file.ServerRelativeUrl } } # Export to CSV $exportData | Export-Csv -Path $outputCsvPath -NoTypeInformation - After running the script, open the CSV in Excel—you’ll have all the full URLs ready to turn into hyperlinks.
If you want a zero-effort approach without scripts, use SharePoint’s native export feature:
- Navigate to your target SharePoint folder.
- Click the Library tab at the top of the page, then select Export to Excel.
- Open the downloaded Excel file—look for columns like
PathorFull URL(naming varies by SharePoint version) that contain the direct links to your files. - Pro tip: Filter the SharePoint library view to only show your target folder before exporting, so you don’t get extra files you don’t need.
This lets you import file paths straight into Excel without downloading a CSV first:
- Open a new Excel workbook.
- Go to the Data tab > Get Data > From Online Services > From SharePoint Online List.
- Enter your SharePoint site URL, sign in, then select the library that houses your target folder.
- In the Power Query Editor, use the Folder Path column to filter for only your target folder’s path.
- You’ll see a
Full PathorURLcolumn with all the file links—click Close & Load to bring this data into your workbook. - To turn these into clickable hyperlinks, use Excel’s
HYPERLINKfunction in a new column:
(Replace=HYPERLINK(A2, B2)A2with the cell containing the full URL, andB2with the filename you want to display as the link text.)
Once you have the list of URLs in Excel, you can either use the HYPERLINK function for bulk links, or select the URL column, right-click > Link to assign links manually (though the function is way faster for 200+ entries).
内容的提问来源于stack exchange,提问作者MLaser

