(Sharepoint) Create metadata based on folder or filename

Menno Diesveld 1 Reputation point
2020-12-22T08:28:56.827+00:00

Hi,

I'm working on a new libary, i want to migrate the old "Explorer" folder libary to a new metadata based structure. At this moment there are over 1000 files in different folders. Now i want to add the metadata to the file based on the folder name or based on the file name. I already tried to do this using MS Flow, but i have no idea how to get this working.

Can somebody point me in the right direction?

Thanks in advance

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,566 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jerry Xu-MSFT 7,921 Reputation points
    2020-12-23T08:00:26.1+00:00

    Hi, @Menno Diesveld ,

    If you want to use Flow to upload files, you will need to use File System actions. This connector needs to have On-Premise Data Gateway configured before. As I am not an expert on Power Automate, you can have a test about it and post in Power Automate Forum for more information.

    Here are some tutorials on configuring Data Gateway:

    accessing-your-on-prem-data-using-on-prem-data-gateway

    use-local-file-system-with-microsoft-flow-fa6a2caaa1c3

    And you can take using PowerShell as an option. With Pnp module, we can easily use Add-PnpFile to upload files to SharePoint library with required metadata value.

    Here is my demo:

    #Skip this line if you have installed PNP module  
    Install-Module SharePointPnPPowerShellOnline  
    Connect-PNPOnline -URL <siteURL>  
    Add-PNPFile -Path "<FilePath>" -folder "Shared Documents" -values @{Title="FolderName"}  
    

    This simple script uses file path to upload the file to Documents, setting the title to be FolderName.
    50794-image.png

    And according to your description, you need to use the folder name as the metadata. So how is the folder name located in the path? Does it has a fixed location or with any other rules? And how many fields will need to be handled?

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments