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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to Store Files to ...
Power Automate
Answered

How to Store Files to Respective Folders.

(0) ShareShare
ReportReport
Posted on by 80

Hi Guys,

 

I am new to Power automate and I have this problem statement where

 

I have 6 country files which needs to be stored in sharepoint doc lib through flow which is getting triggered from App. but the catch is I have folder structure of these 6 Countries in sharepoint site and these 6 files go to respective folders.

For Ex: 

Countries - Malaysia;Oman;Pakistan;Philippines;Switzerland;US - Deer Park

Country Abbriviation - Malaysia;Oman;Pakistan;PSPC;SBI;Deer Park

(County and country abbrivition above stored in sequence)

 

Country Abbriviation - File name contains these keywords then it should got to that country folder. 

This can be easily achievable if I hard code these values in flow.

but going forward in future there might be more countries and I need to change the flow everytime.

 

So I stored these country and country abbriviationn in sql table and read those values applied split and stored values in variable.

but now I am stuck here how to apply each file compare its Abb and sent that file to exact country folder.

For Every file I have to compare its name with country abbrivition. if name contains Abb then it should go to respective country folder.

 

Any solution, Way of approach to this problem would be appriactied.

which datatype variable should be used how to do it. 

 

Thanks

Categories:
I have the same question (0)
  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    I'd probably set up a SharePoint List that could provide the mapping between Abbreviation and Country. You can then add to the list as you add more countries. This way you'd never have to update the Flow each time.

     

    My list would look something like this:

    grantjenkins_0-1666355701565.png

    For this example, I've setup a folder that contains the files that need to be moved (Country Files) and the destination Country folders.

    grantjenkins_1-1666355752421.png

    grantjenkins_3-1666355765635.png

    For the actual Flow there are a few ways you could do it. I'd probably do the following:

    1. Get all the items from the Countries List
    2. Get all the files (properties only) from the Country Files folder
    3. Loop through each of the items in the Countries List and for each one:
      1. Filter the files to get only ones where the Name contains the country abbreviation
      2. For each of the files that matched:
        1. Move the file to the corresponding Country folder

    See full flow below. I'll then go into details of each action.

    grantjenkins_4-1666356047519.png

     

    Get items and Get files (properties only) just retrieve all the items and files (assuming you only have files in the source location - no folders):

    grantjenkins_5-1666356177340.png

    Apply to each country loops over all the items in the Countries List.

    It then uses Filter Array to filter the files using Name contains Abbreviation.

    Name uses:

    item()?['{Name}']

    Abbreviation uses:

    items('Apply_to_each_country')?['Abbreviation']

    This will result in an array of files that match the current abbreviation.

    grantjenkins_6-1666356452667.png

    Finally, it loops through each of the files that matched the abbreviation and moves each file using Move file.

    File to Move uses:

    items('Apply_to_each_file')?['{FullPath}']

    Destination Folder uses:

    concat('Shared Documents/Countries/', items('Apply_to_each_country')?['Title'])

    This joins the base library/folder structure and the corresponding Country folder. You'd just need to provide your base library/folder structure.

    grantjenkins_7-1666356726121.png

  • nejhade Profile Picture
    80 on at

    Hi @grantjenkins 

     

    Thank you for the Great Help.

    List Idea really worked here.

    I have modified above solution and made to store files in respective folders.

    Thanks alot.

    Keep doing great work.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 398 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 331 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 203 Most Valuable Professional

Last 30 days Overall leaderboard