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 / Loop until condition met
Power Automate
Answered

Loop until condition met

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I have PowerAutomate for uploading files to the SharePoint document library. I wanted to check filename is exist or not before uploading the file. If file name is exist, Need to append -1 at the end of the document name. If document already contains with -1 then I need update -2. I wanted to increment the counter at the end. Kindly let me know the feasibility of this in PowerAutomate.  

 

Document

DocumentName-1

DocumentName-2

Categories:
I have the same question (0)
  • lschafroth Profile Picture
    3 on at

    I am looking for the same. I tried date and time but Sharepoint changes the format of the date and time therefore killing the filename.  I cannot load the file later as the name is now different.

  • Verified answer
    Mister_Shaik Profile Picture
    1,008 on at

    Hi @Anonymous @lschafroth ,

     

    To check for any existing file exists with same name, you can use the following solution

     

    1. Set a variable to collect the file number to append
      1. set a variable to count file number.PNG
    2. Add a Do until - the loop runs until it finds no conflict with file name, if a conflict is there, it will increase file number and loop continues
      2. Check until no conflict with file name.PNG
    3. Once there is no conflict, the loop exits and we can decrement the file number to use it in file name
      3. Decrement the file number and use it to save the file.PNG

     

    I have passed a static file name here  "Book.xlsx". In case it's dynamic for you, you can split the file name with "." and the file name to check would be first(split(#filename, '.')) + fileNumber + last(split(#filename, '.'))

     

    Hope you find this helpful! 🙂

     

    Kind Regards,

    Shaik Sha
    ________________________________________________________________________

    If I have answered your question, please mark the post as Solved.
    If you like my response, please give it a Thumbs Up.

     

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!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 304

#2
David_MA Profile Picture

David_MA 245 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 243 Most Valuable Professional

Last 30 days Overall leaderboard