Skip to main content

Notifications

Community site session details

Community site session details

Session Id : cZo3lFl92isu6YlTQ16fj2
Power Automate - Building Flows
Suggested answer

Upload Files from OneDrive to SharePoint Based on File Names

Like (1) ShareShare
ReportReport
Posted on 31 Mar 2025 18:26:01 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?

  • Suggested answer
    Michael E. Gernaey Profile Picture
    42,032 Super User 2025 Season 1 on 01 Apr 2025 at 20:55:48
    Upload Files from OneDrive to SharePoint Based on File Names
     
    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?
  • JS-31031814-0 Profile Picture
    4 on 01 Apr 2025 at 11:20:49
    Upload Files from OneDrive to SharePoint Based on File Names

    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
    42,032 Super User 2025 Season 1 on 01 Apr 2025 at 04:17:43
    Upload Files from OneDrive to SharePoint Based on File Names
     
    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
     

     
  • ronaldwalcott Profile Picture
    3,653 on 31 Mar 2025 at 19:44:14
    Upload Files from OneDrive to SharePoint Based on File Names
    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 97

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 70 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard
Loading started