Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Copy most recent file from one folder to another and rename file

(0) ShareShare
ReportReport
Posted on by 207

We have 2 folders...

 

Folder 1: Used to store a daily data output fileS (.xlsx) in.  Each daily file is named similar to "Daily_Spend_Service_20200828_000148", but with the date section changing.

Folder 2: Used by Power Bi to refresh a data report. Power Bi looks for a file called "Upload" in the folder.

 

We need a flow to copy the most recent file found in Folder 1 and copy it to Folder 2, once the most recent file is in folder 2, delete the previous file called "Upload" from folder 2 and rename the newly copied file to "Upload".

 

Is this possible?  Very new to creating Flows, so any guidance would be great.

  • efialttes Profile Picture
    14,756 on at
    Re: Copy most recent file from one folder to another and rename file

    Hi!

    In order to copy newest file from folder 1 to folder 2 I would do the following:

     

    Set 'Get files (properties only)' by selecting target site, library name and folder... Set 'Top Count' input to 1 and type the following ODATA expression to 'Order by' input

    Created desc

    Next add an 'Apply to each' action block, assign as its input 'Get files (properties only)' value output... this 'Apply to each will be executed 1 time only, since 'Top Count' was set to 1

     

    Now inside the Apply to each I would add 'Copy file' action block. GReat stuff in this article on this action block

    https://www.chakkaradeep.com/2018/10/10/new-and-improved-sharepoint-copy-move-actions-for-microsoft-flow/

     

    Once you get this part running please let us know so we will work on renaming and deleting

    Hope this helps

  • StuartSmith Profile Picture
    207 on at
    Re: Copy most recent file from one folder to another and rename file

    Sorry, yes, both folders are located in Sharepoint Documents...

     

    Documents\Folder 1

    Documents\Folder 2

  • efialttes Profile Picture
    14,756 on at
    Re: Copy most recent file from one folder to another and rename file

    Yes we can!

    But, we need some more context info...

    Onedrive? Onedrive4Business? Sharepoint?

    Thanx!

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May 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 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492