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 / How to check the versi...
Power Automate
Answered

How to check the version of the same filenames

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

I have two files with the same file name but different version. I need to check the latest version and copy them to the folder. 

Any ideas on how to implement ?

 

File names : 10mL ABC 19875-05.pdf

                    10mL ABC 19875-06.pdf

 

Currently, I am getting the files in a folder which has 10mL ABC 19875*.pdf, so I am getting all the files which matches. I need to copy the file which has 06.pdf. Please help.

 

 

I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @Anonymous 

     

    We have "Sort by" dropdown menu in Advanced options in action "Get files in folder". You should make it sort by "Name" and let it "Descending" order in this scenario.

     

    shindomo_0-1633602836756.png

     

    Using configuration above, the latest version of your files will always be at the beginning of the %Files% list.

     

    shindomo_1-1633603285772.png

     

    Then you can copy the latest version of file referring by %Files[0]%

     

    shindomo_2-1633603305788.png

     

    Thank you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you @Anonymous 

    It is so helpful! one more thing, for suppose I have many files having same file names and different version and I have to keep the latest, rest of the files have to be deleted because I am working on the same folder so instead of copying, I prefer to delete the unwanted files. 

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    Assuming all files are formatted the same way, ex. ##ml XXX #####-##.pdf, then you could do the following:

     

    • After you have sorted as previously indicated by @Anonymous, 
    • For Each %CurrentItem% in %Files% 'CurrentItem in this case would be each row ex. %Files[0]%
      • Get Subtext of %CurrentItem.Name%, Start of Text, character position = 0, Length is Number of Characters = 15; set the subtext to %NewSubText%
      • If %CurrentItem% = %Files[0]%
        • Set variable %LastSubText% to %NewSubText% 'on the next loop, we will match these up
        • Next 'this will ignore the first file and move to the next file
      • EndIF
      • If %NewSubText% = %LastSubText%
        • Delete %CurrentItem%
      • EndIF
    • End 'For Each

     

    This will loop through each filename ignoring the first time the 15-character string pops up.  Each line will look for a match from the previous 15 characters, and if they are a match, it will delete the file, if not, it will move on.

     

    Best of Luck!

     

     

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @Anonymous 

     

    Just remove the item %Files[0]% from the list.

     

    shindomo_1-1633619587278.png

     

    After that, you have the list of files except the latest one. That's the list of files you want to delete.

     

    shindomo_2-1633619676077.png

     

    Now you can delete files except the latest one using variable %Files%. It's so simple, but it works well as you imagined. 🙂

     

    shindomo_0-1633619559487.png

     

    Thank you.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @MichaelAnnis 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @Anonymous 

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 282 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 159 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 146 Super User 2026 Season 2

Last 30 days Overall leaderboard