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 / copy last file in shar...
Power Automate
Answered

copy last file in sharepoint folder, rename it and ad current week number. Repeat the process with the file from the previous week

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello 🙂

Every Wednesday morning I take an existing file, duplicate it in the same folder and change the file name to the current calendar week. Then I send the file via Outlook to the same people. A week later I take the file from the previous week and repeat the process. Can you help me to create an appropriate workflow

Thank you!

Categories:
  • Rhiassuring Profile Picture
    8,692 Moderator on at

    Hi there, 

     

    Is the Excel file the only file that exists in that particular folder?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Rhiassuring

    no every week we put the new copy of last week in the folder. At the end of the year we have 52 files in there.
    But if it's easier, you could adjust the flow so that first a copy of last week's file is created and then the old file goes into an archive folder created for it. But for this I would need the corresponding workflow.

    Thank you for your help!

  • Rhiassuring Profile Picture
    8,692 Moderator on at

    I gotcha. Working on a solution for you.

  • Verified answer
    Rhiassuring Profile Picture
    8,692 Moderator on at

    Okay, here you go: 

     

    Rhiassuring_0-1674165488282.png

     

     

    Step 1) Use a recurring trigger - every Wednesday!

     

    Step 2) Get Files (Properties Only) -- use "Created desc" in your Order By so you're only getting the most recent. (This way you can keep all your weekly Excel outputs in the same folder, no problem.)  Set "Top Count" to 1 so we only get the most recent.


    Step 3) "Get File Content" and point it to the Identifier from your Get Files output. It'll turn into an apply to each, but don't worry, it'll only apply to one.

     

    Step 4) Create File - point it back to the same folder. Set the file name to (and I made an assumption here you're counting the week) -- I have it as (for example) Week-3.xlsx. The formula to identify the # of the week in the year is add(div(dayOfYear(utcNow()),7,1).  Point File Content at the File Content from Get File Content.

     

    That should do it. Works for me, let me know how it goes for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    thanks that helped a lot!

    Could you also help me to put the sharepoint link of the new file we just created into an outlook e-mail?

    Best regards
    Lars

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    My problem is the link to file that I have in my outlook email directs not to the file I just created. It directs to an older file in this folder.

  • Rhiassuring Profile Picture
    8,692 Moderator on at

    You can just use the dynamic content of the "Create File" action. That'll have the path to the new file.

  • Aleona Profile Picture
    2 on at

    Hi, i tried this solution to search for the latest file added to a Sharepoint folder (including all subfolders), then copy the most recent file to the second Sharepoint folder with a name "REP021_latest.xlsx" (this is the file from which we create an excel report with PowerQuery). But i keep getitng this error: 
    The attempted operation is prohibited because it exceeds the list view threshold.
    clientRequestId: 05565bda-d7ea-4877-8686-4a350c1c533b
    serviceRequestId: 05565bda-d7ea-4877-8686-4a350c1c533b
    Attached is a screenshot of the flow. 

    Are you able to assist please? Thanks. 
    Using Power Automate for the first time. 

    Thank you. 

    Capture.PNG
  • sankar1 Profile Picture
    2 on at

    Hello, I'm getting the following error : 

    "The attempted operation is prohibited because it exceeds the list view threshold.
    clientRequestId: 80458920-bc2f-403a-af02-41431dfdf6c4
    serviceRequestId: 80458920-bc2f-403a-af02-41431dfdf6c4"

     

    Please support to resolve this error

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 292 Super User 2026 Season 2

#2
Henil Profile Picture

Henil 128

#3
anirudhev Profile Picture

anirudhev 124

Last 30 days Overall leaderboard