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 / Adding Variable to fol...
Power Automate
Answered

Adding Variable to folder path one drive

(0) ShareShare
ReportReport
Posted on by 20

Hello, I am pretty new to powerAutomate, trying to build a flow which transfer a file from daily created folder on onedrive to the same daily folder on SP.

In the Sp folder path i was able to add utcNow indicartor, so that proper folder is picked. Is anyone able to help me how to replace the 28-06-2023 in the One drive folder path ?

Karinka_0-1687949381820.png


Additionally, is there any way to transfer files bigger than 50MB from onedrive to SP?

Categories:
I have the same question (0)
  • rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @Karinka ,

     

    To get the current date and transform it to '2023-06-28' format, you can use this expression: formatDateTime(utcNow(), 'yyyy-MM-dd')

     

    In your case, you are trying to add it to the flow trigger, and apparently this is not allowed in Power Automate. I see two possible options here:

     

    Solution 1:

    As your daily folders are all allocated at the same "parent folder", you can add the parent as source and set the "Include subfolders" as "yes" in your "advanced options":

    rzaneti_0-1687950551216.png

     

    As an intermediary step, you can add a conditional to validate if the file was created in today's folder. If you do not know how to use conditionals in Power Automate, you can check this blog post (and, of course, we can walk you through this process if the 'Solution 1' makes sense for you): http://digitalmill.net/2023/06/23/using-conditions-ifs-in-power-automate/

     

    Solution 2:

    If you do not need to have this files uploaded to SharePoint in real time, it is possible to design a flow that checks the OneDrive in a recurrent basis (in each our, or in each 10 minutes) for new files and copy them.

     

    For the "Create file" action in SharePoint connector, apparently the current limit is 100MB. Check this thread for more details: https://powerusers.microsoft.com/t5/General-Power-Automate/File-size-limit/td-p/1544841#:~:text=The%20maximum%20message%20size,the%20action%20content%20transfer%20settings.

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

  • MO-30121343-0 Profile Picture
    20 on at

    Hi @rzaneti 

    Thanks for coming back to me so quickly!

    So the first scenario definitely meets the requirements. 
    If that is easier the entire folder might be moved to SP from one drive, but could not figure out how to do that. Have seen only files level (not folder) connectors for one drive. 

    Anyway, can you help me in fitting in those conditions for file creations ?
    I initialized variable for file creation to utcNow, but there is no Date data type, so shall it be string in this case ?


    also when it comes to the MB limitation, seems like there is a limitation at onedrive for business end:

    When a file is created

    Operation ID: OnNewFileV2

    This operation triggers a flow when a new file is created in a folder. Files larger than 50 MB will be skipped and not returned by this trigger. Files moved within OneDrive are not considered new files.

  • Verified answer
    rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @Karinka ,

     

    About the folder from OneDrive to SP you are correct: Power Automate accepts only the files. However, when moving your files to SP, you do not need to create the folder previously: if the folder does not exists and you pass it as a path in the "Create file" action, it automatically generates the folder. Check the example below 🙂

     

    About the MB limitation, you are correct. Apparently the trigger won't even be called if you have a file larger than it!

     

    Overview:

    I have a folder in OneDrive (origin) containing some subfolders with the same name convention as yours (date in format yyyy-MM-dd). Initially, all subfolders are empty, and my goal is to automatically move any file created inside these subfolders from OneDrive to SharePoint, in a folder called "landing folder". Inside "landing folder", I want to keep the same subfolder structure: if I create a file inside the subfolder "2023-06-27" in OneDrive, I want it to be replicated in a subfolder also called "2023-06-27" in SharePoint.

     

    OneDrive:

    rzaneti_0-1687970291769.png

     

    SharePoint:

    rzaneti_1-1687970326553.png

     

     

    Step 1 - Trigger:

    As mentioned before, we will use a 'When a file is created' trigger, passing the parent folder as input (in my case, the folder called 'origin') and assigning the 'Include subfolders' option as 'Yes':

    rzaneti_2-1687970421332.png

     

    Step 2 - Getting new file details

    Our trigger does not return the details from the new (full path, file name), so we need to use 'Get file metadata' action from OneDrive connector to get it. Also, to insert the file into SharePoint, we will need to copy the file content, by using the 'Get file content' action. Both actions use the same input: the File Identifier extracted from trigger:

    rzaneti_3-1687970582948.png

     

    Step 3 - Isolating the subfolder path:

    As we want to keep the same subfolder structure, we need to extract it from the file path. To achieve this, we need to use a text expression that will remove either the "file name" and the folder path between OneDrive root and our parent folder.

     

    For example, if I create a file called 'Document.docx' in '2023-06-27" subfolder, the file path returned in 'Get file metadata' action will be '/Community/origin/2023-06-27/Document.docx', and from that I only want to extract the '2023-06-27/':

    rzaneti_4-1687970851581.png

     

    So we will initialize a string variable (I called it 'relative_path') and use the following expression: 

    replace(last(split(outputs('Get_file_metadata')?['body/Path'], 'origin/')), outputs('Get_file_metadata')?['body/DisplayName'], '')
    rzaneti_5-1687970932378.png

     

    For your use case, make sure to replace the highlighted text for:

    • Green: File path from 'Get file metadata' action (you can get it dynamically)
    • Red: Your parent folder name
    • Blue: Display name from 'Get file metadata' action (you can get it dynamically)

     

    Step 4 - Create the file in SharePoint:

    Finally, we will use a 'Create file' action from SharePoint connector passing your parent folder in SP as input, and connecting it with 'relative_path' as dynamic content. As file name, we pass the 'File name' dynamic content from 'Get file metadata' action, and as file content we pass the 'File content' dynamic content from 'Get file content' action:

    rzaneti_6-1687971288972.png

     

     

    Final result

    To test the flow, I created a new file into '2023-06-27' subfolder in OneDrive:

    rzaneti_7-1687971368287.png

     

    It automatically created the '2023-06-27' subfolder in my 'landing folder' from SharePoint

    rzaneti_8-1687971436283.png

     

    And stored a copy of the OneDrive file inside it:

    rzaneti_9-1687971461379.png

    This is the complete flow design:

    rzaneti_10-1687971478125.png

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    adsfsasad

  • MO-30121343-0 Profile Picture
    20 on at

    Hi @rzaneti , that's extremely comprehensive! thanks for that.

    for me marking the  Include Subfolders to "yes" did the magic.

    I tried your solution and unfortunately my flow fails in the create file on SP step with some notification around using inappropriate signs... but possibly i did something wrong.
    My work around is to include in the Folder Path utcNow('dd-MM-yyyy') function, it works perfectly fine as well 🙂

    If you can just reply to my last questions, as i do not quite understand. You have added a interim steps to get new file details, file name and file content, whereas my flow works fine without those, shall i add those steps anyway ?

    Karinka_0-1688121913075.png

     




  • rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @Karinka ,

     

    I'm glad to know that everything is working fine!!

     

    About your question, your are correct: we do not need to use the 'Get file content' action, as this data is already returned from the trigger. When I was building the flow, I actually did not realize that we could pull it directly from the trigger, so I included this extra step 😅

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