web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create SharePoint list...
Power Automate
Suggested Answer

Create SharePoint list items from library files and set Title from parent folder

(1) ShareShare
ReportReport
Posted on by 2

Hi Community,
I’m looking for help building a Power Automate flow that reads documents from a SharePoint document library and creates one SharePoint list item per document.

1) Folder structure (fixed depth)

In my SharePoint document library, the structure is always:

  • Root folder

    • Customer 1

      • Document A

      • Document B

      • Document C

      • Archive

        • Archive Document 1


      •  

    • Customer 2

      • Documents …

      •  

The depth is always: Root → Customer → (optional Archive) → Files

I want to process files only (documents), not folders.

For each file, create a SharePoint list item with:

 
  • The list’s Title column (renamed to “Customer” in the UI) should be the customer folder name, not the file name.

    • If the file is directly inside the folder "Customer 1", Title should be: "Customer 1"

    • If the file is inside "Customer 1/Archive", Title should be: "Customer 1_Archive"


    •  

  • The actual document file name in the library should not be changed (only the list item Title).
 

My flow currently looks like this:


  1. Manually trigger a flow

  2. Get files (properties only) (SharePoint)

  3. Filter array: IsFolder equals false

  4. Apply to each

  5. Create item (SharePoint list)


  6.  
 

I tried to set the Title directly via an expression that extracts the parent folder name from FileDirRef (or FileRef) and appends _Archive when the path contains /Archive but its always null the value I’m using (e.g., item()?['FileDirRef'] or item()?['FileRef']) is null, even though I expected only file items.

So what is the best/robust approach to ensure the loop processes files only (no folders), and renames them as the foldername they are in 

 

I attached screenshots of the folder structure and the current flow configuration

Thanks a lot in advance!

Screenshot 2026-0...
Screenshot 2026-0...
Screenshot 2026-0...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

Categories:
I have the same question (0)
  • Suggested answer
    sumit_artesian Profile Picture
    91 on at
     
    If your folder structure is consistent, here is how you should structure your flow to achieve your requirements:
     
    Overall flow:
     
    1. Get files (properties only):
    1a. Library Name: Select your Root Folder. I am using the PP_Community library for this example.
     
    2. Apply to each: Select body/value from the previous step.
     
    3. Condition: items('Apply_to_each')?['{IsFolder}'] is equal to false
     
    4. Create item:
    4a. List Name: Select the list that you want to add an item to. I am using PP_Community_List for this example.
    4b. Title: 
    if(
      equals(length(split(replace(item()?['{Path}'], 'PP_Community/', ''), '/')), 3),
      concat(
        first(split(replace(item()?['{Path}'], 'PP_Community/', ''), '/')),
        '_Archive'
      ),
      first(split(replace(item()?['{Path}'], 'PP_Community/', ''), '/'))
    )
    Note: Replace 'PP_Community/' in the formula with your Root Folder name everywhere. This expression will remove the library name from the path and then split the path based on the character '/'. If the split contains three items, i.e., Customer Folder Name, Archive folder, and an empty item (because the file path has a trailing '/' which leaves an empty item in the end), it will create the item with Title as CustomerName_Archive. If it has two items, i.e., Customer Folder Name and an empty item, it will create the item with Title as CustomerName.
    4c. File Name (Optional): I have optionally added the file name as well. Formula: items('Apply_to_each')?['{FilenameWithExtension}']
     
    Here are the results:
    Library:
     
    List:
     
    Please  Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item.
    If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like! 🩷

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 881

#2
Valantis Profile Picture

Valantis 823

#3
Haque Profile Picture

Haque 485

Last 30 days Overall leaderboard