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 / Move Files in SharePoi...
Power Automate
Answered

Move Files in SharePoint, Only if They Have a Certain Name

(0) ShareShare
ReportReport
Posted on by 5

I have been able to moves files under a folder from one to another in SharePoint. But for the life of me I cannot figure out how to only moves files that start and end with a certain file name.

 

I have tried looking around forums of many kinds, but I have not seen anyone with my specific problem. I want to move files that start with a certain combination of numbers and letters, and the file name ends with the previous day's date.

The goal is to move files of a certain group every day to another file location, the folder they start in has many other files that need to be skipped. The flow should recognize that they start with a certain name and that they're files from the day previous, move them to the destination folder, then repeat this every day.

I have tried using conditionals and variables, but I end up with errors about wrong data type. 

I appreciate any insight into how this might be solved, or another way to go about moving SharePoint files.

 

This is the code that moves files, this does work, but when I try to add variables and conditionals it fails:

PA-ForumQuery.PNG

Categories:
  • Verified answer
    Expiscornovus Profile Picture
    33,997 Most Valuable Professional on at

    Hi @Clark_bar,

     

    The Get files (properties only) action has a Filter Query field (under the show advanced options button). You can use an OData query in there with startswith and substringof functions:

    https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-odata-query-operations-in-sharepoint-rest-requests#odata-query-operators-supported-in-the-sharepoint-rest-service

     

    Below is an example.

    In this case I am using utcNow  and subtract one day (aka yesterday). That is formatted into 25-07-2023. This sample also assumes the file is a Word document (aka .docx). It checks if the File Name (FileLeafRef).

     

    1. The example file I want to retrieve

    example_file.png

     

    2. The OData filter query which combines substringof and startswith functions.

     

     

    (substringof('@{concat(addDays(utcNow(), -1, 'dd-MM-yyyy'), '.docx')}',FileLeafRef)) and (startswith(FileLeafRef,'Contoso'))

     

     

     

    fileleafref.png

     

     

  • Clark_bar Profile Picture
    5 on at

    Thank you @Expiscornovus! This works great!

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
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard