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 / If file exist, rename ...
Power Automate
Answered

If file exist, rename file with parenthesis (1),(2),(3) etc

(0) ShareShare
ReportReport
Posted on by 141

Hi, 

 

Wondering if it is possible to if a file already exist to rename it with a parenthesis. I'm trying to get around the "Do nothing" if same file already exist as I have multiple files that need to be named the same name but with a (1) (2) or (3) etc on the end. Any help on this would be most appreciated, thanks. 

I have the same question (0)
  • Verified answer
    jkingno1 Profile Picture
    141 on at

    Found the solution which was just to generate a random number and add it to the end of the renamed file

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    For this %ToFile% is your entire filepath and filename for the file you are trying to save, so it would already be defined at this point:

     

    Set variable %VersionCounter% = 0

    Label:  CheckFile

    If file exists %ToFile%

        Set variable %VersionCounter% = %VersionCounter + 1%

        Append _(%VersionCounter%) to Text %ToFile% ' now %ToFile% has the number on it such as filename_(1)

        Go to Label CheckFile 'this will loop back around and make sure filename_(1) is available.

    End (if) 'it will only come here if the file doesn't exit

    Rename File

     

    Good luck!

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 246 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 176

#3
Haque Profile Picture

Haque 157

Last 30 days Overall leaderboard