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 / Upload Files from OneD...
Power Automate
Suggested Answer

Upload Files from OneDrive to SharePoint Based on File Names

(1) ShareShare
ReportReport
Posted on by 4

Hello,

I am trying to build a flow for automatically uploading files to the appropriate SharePoint folders based on their subject.

For example, if an Excel file name in the OneDrive folder contains "AA", then move the file to "sharepoint/AA". If it contains "BB", then move it to "sharepoint/BB", and so on.

I followed the tutorials for "list rows present in a table", but it does not work. The condition returns false even if the file name contains the code from the table.

Could you please help me resolve this issue?

Categories:
I have the same question (0)
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    There are several examples which can assist you. See Move files to folders based on file name with Power Automate as one of these examples
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,414 Super User 2025 Season 2 on at
     
    Thank you for your post and thank you for sharing the photo. Unfortunately the important part is actually the Expression itself.
     
    So can you please do the following.
     
    In Design mode
    1. Please list the expressions you have in the left, middle and right side of the condition (middle isn't an expression I know but show what is there)
     
    In run mode
    2. Go back to your flow run that didn't do what you wanted
    3. Open the Condition and look at the inputs and check. What we need to see is 
     
    This way I can verify what you selected and help you identify the issue.
     
    Now let's talk about your flow.
     
    Step 1:  When a file is created, this is fine
    However, you should not do a List rows.
    You Said
    For example, if an Excel file name in the OneDrive folder contains "AA", then move the file to "sharepoint/AA". If it contains "BB", then move it to "sharepoint/BB", and so on.
     
    So, there is no reason to do List rows as that is the data inside the Excel and will not be used to determine if the file should be moved.
     
    Step 2 let's talk about it
     
    Now, Question, how many possible Checks do you have? You said AA and BB, but we have to come up with a plan for identifying how many matches do you have.
    File Name contains A,B,C,D,E,F  etc etc because we have to solve it as if its a list.
     
    So here is what I would like to Suggest.
     
    I would create a SharePoint List. Let's pretend it's called File Name Mapping
    Let's pretend you have the following
     
    AA   sharepoints/AA
    BB   sharepoints/BB
    CC    sharepoints/CC
    DD  sharepoints/DD
    EE   sharepoints/EE
    FF   sharepoints/FF
    GG  sharepoints/GG
    HH  sharepoints/HH
     
    I would create a SharePoint List and add these columns
     
    Mapping String          SharePoint Folder
    AA                              sharepoints/AA
     
    And so on. All the above would be there.
     
    So your Step 2 would look like this
     
    Get Items (from the SharePoint list we called "File Name Mapping")
    Loop through the records
    --add a Condition inside the loop
    ------Left Side Dynamic File Name property from Trigger in the middle select Contains right side put item?['Mapping String']
    ---------In the Yes side, we know that the string WAS inside the filename so we can move it using the Move Item action
    ---------In the NO side do nothing
     
    This would allow you to create a dynamic way of adding more Mapping strings
     
    NOTE: I didn't add any steps to Create the subfolder in SharePoint as I expect it to be there.
     
    But this will do what you asked in a Dynamic way. Meaning you can add any new mappings at any time and they will just automatically work without any redeloying
     

     
  • JS-31031814-0 Profile Picture
    4 on at

    Hello Michael,

    Thank you for your help.

    I am adding more screenshots.

    The code and the destination folder is in table13 (on screenshot)

    It works fine until the "condition" - as you can see in the screenshot, even if the file contains "MS50," the result is false and no file is uploaded.

     
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,414 Super User 2025 Season 2 on at
     
    You have been explaining it incorrectly. You never mentioned that you had a mapping column in an Excel that you wanted to iterate through.
     
    Also i do not see any file names yet, I only see your flow. So we are still at the exact same place as before.
     
    Did you create that excel because I mentioned how to do it dynamically or was it there the whole time and you didnt explain correctly your flow.
     
    Please... share... file names... and make sure that your full flow opened
     
    I literally see no step in there that load all the File Names to be compared against the Code. So what is your condition actually doing?

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…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard