web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Duplicate FIles in a s...
Power Automate
Unanswered

Duplicate FIles in a sharepoint

(0) ShareShare
ReportReport
Posted on by 10

I have a flow that I am using to upload a file (an image) to a sharepoint folder. The issue I want to avoid is having duplicate file names replacing the old ones. Is there a way to check the filename against the directory and if the name already exists to aphend a _1 _2. (ex. xxx_1.jpg xxx_2.jpg) like windows would? If not is there some other unique identifier I could append to the file name besides a timestamp to prevent the file overwrites?

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @jstryk 

     

    You could use Move file action step or Filter Query. Please have a look at my videos.

     

    https://www.youtube.com/watch?v=B9ZxAd9JVVo

     

    Also you can filter using the filter query

     

    https://www.youtube.com/watch?v=bSkWdDnhCmQ&t=1s

     

    Thanks

     

     

  • tom_riha Profile Picture
    10,185 Most Valuable Professional on at

    Hello @jstryk ,

    I can imagine a solution using 'Get files' on the library with 'Filter Query' to check if there're already files with that name. The 'Filter Query' below will check if there're files that already contain the filename and return all of them.

    substringof('[FileName without extension]', FileLeafRef)
    
    Note:
    [..] is a placeholder, it must be filename WITHOUT extension

     e.g. if your file is xxx, it'll return xxx.jpg, xxx_1.jpg, xxx_2.jpg.... all files that have the filename in title will be stored in the 'value' dynamic content. Then you use expression length('value') to calculate how many items were found, and you add that number at the end of the new file (1st file doesn't have any number, 2nd has _1, 3rd _2...).

    There're limitations though. If the file names are similar, e.g. files xxx.jpg and xxxyyy.jpg, it'll return both when searching for xxx in file name (and you'll get files xxx.jpg, xxxyyyy.jpg, xxx_2.jpg). And also if there're multiple files with the same name uploaded at the same time they could both use the same number.

    In the end I think using a timestamp is much easier and probably more reliable option.

     

  • jstryk Profile Picture
    10 on at

    So I attempted to use the Move File sharepoint action in the flow but it errors out because the source and destination folder are the same. For some more clarification the file (image) is named in the app itself and duplicates are going to be very common because it is going to be named with a non unique identifier. My thought after seeing the file move action was to just compare the "JPG name"(name of the file) field I have in the power app against the directory and then use respond to power apps to just notify the user before any file creation takes place.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard