SOLVED

How to export files to SharePoint document library with metadata

Copper Contributor

Hello All,

 

I have 1000s files. I also have several metadata to be assigned to each file.

I want to upload those files into my SharePoint document library.

I am planning to create and cvs/excel file and add all files name and assigned them with metadata.

Then I want to upload all files into the document library  and assign those metadata automatically via PowerShell.

But I do not know how to do it.

 

I hope some of you may know the solution.

 

Looking forward to hearing from you.

 

Thanks.

4 Replies
best response confirmed by nnkaya (Copper Contributor)
Solution
If you have exactly the same metadata in the source and destination library, the Move to option should move not only the files, but also their metadata. I would recommend to make a test of this feature to evaluate how it works. If you still decide to go for the scripting option, here you have a sample of how to do it: https://www.sharepointdiary.com/2016/06/upload-files-to-sharepoint-online-using-powershell.html (Please, bear in mind that you might to update the PowerShell cmdlets being used in the sample)

Hi @Juan Carlos González Martín, It does not work in this way.

 

We have M-Files application. This application stores all files and then categorize them by metadata.

 

When I export the files from the M-Files, it gives me two files. 1-An excel that shows all metadata. 2-Folder that shows all Files/documents.

 

To upload all documents in a SharePoint document library is easy.

 

But then I have to g into the document library and create each metadata that is in the excel files and then go through 10.0000 files and assign them to each metadata based on the excel file.

 

However, I think there must be a solution such as:

1-Create SharePoint document library (I can do it manually) 

2-Create all metadata that is in excel sheet(which I got it when I export files from the M-Files application) (I can do it manually ) 

3-Uplaod all files.(I can do it manually or PowerShell) 

So far so good. I need a help from here on...

4-I need a PowerShell script that can upload my excel sheet(from my computer) which has all metadata to the SharePoint document library (created at step-1) and can map/assign those metadata to the relevant files that I upload at step 3.

 

Hope that is clear.

 

Thanks

 

The second link points you to an example about how to update file metadata with PowerShell. The script can be extended to read the metadata from an Excel / CSV file and the logic necessary to iterate through the files and properly update the metadata. Good luck!

Hi @Juan Carlos González Martín ,

 

I tried that with exactly the same excel sheet and the same columns. It gives me the following error:

Get-PnPListItem : No list found with id, title or url 'Bulk'
At line:10 char:14
+ ... ListItems = Get-PnPListItem -List $ListName -PageSize 2000 -Fields "F ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Get-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.GetListItem

1 best response

Accepted Solutions
best response confirmed by nnkaya (Copper Contributor)
Solution
If you have exactly the same metadata in the source and destination library, the Move to option should move not only the files, but also their metadata. I would recommend to make a test of this feature to evaluate how it works. If you still decide to go for the scripting option, here you have a sample of how to do it: https://www.sharepointdiary.com/2016/06/upload-files-to-sharepoint-online-using-powershell.html (Please, bear in mind that you might to update the PowerShell cmdlets being used in the sample)

View solution in original post