Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Making a copy of an excel file in SharePoint and saving it to One Drive

(0) ShareShare
ReportReport
Posted on by

Hello All,

I am new to working with Flows and am excited for the possibility but am getting frustrated with functions that seem to be straight forward from my experience using JavaScript and yet seem overly complicated in flows.  That being said, I would like to solve the problem I have but am open to suggestions of better ways of handling it.  

 

As the subject says, I have new files that are placed in a SharePoint location weekly and I would like to make a copy of this file every Friday and save it into a One Drive folder.  Any help would be appreciated.

 

Thanks,

Ryan

  • Community Power Platform Member Profile Picture
    on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    This is great.  Thanks for the help @DamoBird365 !!

     

    Ryan

  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Hi @Anonymous 

     

    Flows are about triggers, if you want it to be automatic, i.e. based on a new file being created, at which point you can use the file identifier block from the trigger.  If you are looking to continue with a schedule (i.e. every Friday at 5pm) and copy the last modified file from a folder, you would need to use the get files action with a sort on modified and top 1.

     

    DamoBird365_0-1628626132180.png

    When you use the identifier in the get file action, it will put the action into an apply to each (and this can be avoided by using the first() expression) however, the apply to each will only run once and is just as good.

     

    This is the get file content action:

    DamoBird365_1-1628626270089.png

     

    I've a video here on JSON and first() here https://youtu.be/6nJSUNh579w if you want to learn a bit about arrays etc.

     

    Cheers,

     

    Damien

  • Community Power Platform Member Profile Picture
    on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Thats great! By selecting the file within the structure I was able to get a file copied over. and I noticed that it would by default create a text document but by adding the file extension (.xlsx) into the name it worked.  

    How would I create it to be dynamic so that I can choose the most recent file?

     

    Thanks,

    Ryan

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Hi @Anonymous 

     

    The file identifier looks like you’ve manually typed in a string without a file extension? Is it that action that gives the error?

     

    Another spy is that the path you have supplied for OneDrive is UNC or a local network file share path. OneDrive is cloud and would expect you to supply a http path.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • Community Power Platform Member Profile Picture
    on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Sorry I thought I included it in the other message. In the below image you can see the flow with the SharePoint  location identified along with the name of a file I was testing with.  On the right you can see the SharePoint location with the file I am trying to get.  The error I get says the file was not found.

     

     

    sharePointToOne.JPG

     

     

    Thanks,

    Ryan

     

     

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Hi @Anonymous 

     

    I just mean a screenshot to understand what you are doing. If it’s always a copy of the same file, you can just browse to the file on the get file content action. If it’s dynamic and based on when a file is created trigger, you would use the dynamic value file identifier from the trigger.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • Community Power Platform Member Profile Picture
    on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Hi @DamoBird365 ,

    I see that now.  My thought was that I was going to need to use an expression to identify just a portion of the name of a file and thought it would need the contains portion so that it was not looking for a perfect match.  I tried just putting the name of a file in the file identifier and it still says it does find the file.  

     

    All I want is to make a copy of an excel file each week and place it into a One Drive folder.  What do you mean share my action?

     

    Thanks,

    Ryan

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Hi @Anonymous 

     

    Contains expects two parameters, string and value and returns Boolean true/false. You’ve provided one string. Does this help your your understanding? Otherwise what are you trying to achieve? Can you share your action?

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • Community Power Platform Member Profile Picture
    on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Thanks Damien.  I appreciate the help.  I like the method in which you organize files by dates and luckily these files have a similar nomenclature.  I tried to get this flow to run in this setup but am having difficulties.  I used the expression contains(formatDateTime(body('Current_time'),'MM-dd-yyyy')) hoping to be able to grab a file based on the date in the name and when it did not work I tried to run with a specific name of a file I know is present but still cannot find the file.  

     

    Thanks,

    Ryan

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Making a copy of an excel file in SharePoint and saving it to One Drive

    Hi @Anonymous 

     

    You would use a trigger, when a file is created. Then use the action get file content (using the id of the file from the trigger). Finally you would use the one drive create file action with the content from the get file content action. The file name must include the file extension and I think can either be the dynamic file name including extension from the trigger or be a name that you decide yourself. I often use formatdatetime(utcnow(),’yyyyMMddhhmmss’) to prefix my filenames and ensure they are unique.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1