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 / Sharepoint Create File
Power Automate
Unanswered

Sharepoint Create File

(0) ShareShare
ReportReport
Posted on by 4
Hi, I am a total beginner with Power Automate and I need some help with what I think should be a really simple operation.
 
I have a folder on OneDrive with 12 subfolders and I have copied this to a corresponding folder on SharePoint (names the same). What I want Power Automate to do is: duplicate a file on Sharepoint in the corresponding folder when a file is created in the folder (or subfolder on OneDrive).
 
I'm using  OD 'When a file is created' then SP 'Create a file' and I am getting the file, in a unnecessary folder of the same name as the file, created in the root folder rather than in the corresponding subfolder. I think the 'Folder Path' expression might be the problem. I am using Dynamic Content 'File Path'.
 
I've also tried using all the other ready-made Folder Path expressions - no success. I have also tried umpteen expressions generated by Co-Pilot and ChatGPT with no success.
 
Can someone with a human brain help me please?
 
Thanks
 
Sebastian
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at
     
    Here is a sample flow with details
     
    My SharePoint and OneDrive Folders Structures
     
     
    Flow Steps
     
    Step 1. create the trigger 
    Step 2. Get the file metadata using the File Identifier from the trigger. While this step should NOT be necessary, I have noticed lately that the Path returned from the trigger can be simply an encoded string and not actually the root path.
     
    Step 3. I just added this so you can see the Path from the Get file meta data which in my case looked like this
    /drives/b!Fv6mN4mjtEOaJ9h7o8zkOYfG7O7a1VhKszUxVUkKf-LbsyJR-4d2RoXaRyxnVZxh/root:/SampleStructure/BBY01-806954304114_2TB_Drive_09_1_2024.pdf
     
    Step 4. Parse step 3 to get the path only since you dont want the actual root path etc, just the folder structure. Use this code
     
    split(split(outputs('Get_file_metadata')?['body/Path'], 'root:/')[1], concat('/', outputs('Get_file_metadata')?['body/Name']))[0]
    
    This will first split by the root:/ string. which give you a 2 element array
    I want the second half (so [1]
    I then want to split that by the /filename so you can see I use the concat to add the / and i use the Name property of Get file metadata
    (I could do this several ways this was a teaching moment)
     
    Step 5. Create File
     
    But in my Folder Path I do this.
    Where I already selected the starting path (/Share Documents) I added the / and then I use the Output of the Get Folder Structure Path Only compose.
     

     
    When I run it, it works without a hitch, putting the files into the SharePoint matching folder structure.
    So drop in OneDrive Folder1 get it in SharePoint Folder1
     
     
  • SM-10031228-0 Profile Picture
    4 on at
    Hi Michael,
     
    Thank you very much, that has helped me to understand better what is going on - I'm learning!!
     
    I tried to duplicate your flow exactly (See below) and something is still not quite working as I want. I'd really appreciate your thoughts on this again!
     
    Many thanks - Sebastian
     
    The output from the Split operation seems correct:
     
     
    But you can see that in the output from the Create File Step, the extra folder TEST_406.jpg has been added.. That is the name of the file I'm trying to duplicate.
     
     
     
     
    The file is not being duplicated into the correct subfolder but being put into an unnecessary folder of the same name.
     
     

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 801

#2
Valantis Profile Picture

Valantis 602

#3
Haque Profile Picture

Haque 581

Last 30 days Overall leaderboard