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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Move file between Shar...
Power Automate
Unanswered

Move file between Sharepoint folders if older than 30 days AND filename contains

(0) ShareShare
ReportReport
Posted on by

Hi,

I was pleased to create a flow which places the attachment from a weekly email I receive into the 'Files' area of a Teams channel (so, a SharePoint site).

However once the file has been Files for 30 days I want to move it to an 'Archive' folder in the same SharePoint site. 
To avoid inadvertently moving any other files that people drop into 'Files' I want to only move files where the file name contains the specific string 'XYZ'. The files are always in a consistent format and file name always contains this string. 

I have tried multiple methods of achieving this using some methods described here within the forums and others from Jon Levesque's YouTube channel - without success.
Recurrence steps are fine, 'Get Files (Properties Only) are fine, all the failures seem to be in the 'Apply to each' step. 

Does anyone have any tips please?

Thanks

Categories:
I have the same question (0)
  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

    Hello @DamoB 

    Could you share your flow and show which are the errors you are receiving?

  • DamoB Profile Picture
    on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

    Hi, 

    Thanks for responding. I've attached photos of one of my attempts. 
    The expression in the condition is:

    lessOrEquals(items('Apply_to_each')?['Modified'], addDays(utcNow(), -30))
    I think this attempt (there have been many!) i was just trying to get the 30 days thing working so no attempt here to add the 'file name must contain 'XYZ'' part.
     
     

    Move files1.PNGMove files2.PNG

  • DamoB Profile Picture
    on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

    And the error message:Move files error.PNG

  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

    Hello @DamoB 

    As I can see by your screen captures, the error is related to the file identifier (it says Shared Documents/General), where this field should be a number (id field value of the sharepoint document). Have a look at this:

    2020-03-11 19_01_04-Window.png
    Hope it helps!

    Ferran

     

  • DamoB Profile Picture
    on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

    @fchopo Thank you very much. 

    I switched out 'Identifier' for 'ID' unfortunately I get a similar error at the same place. 

    Should the File Identifier field contain an expression that will find the 'XYZ' part of the Title perhaps?

    Or 'Modified'? Or has the modified element been managed in earlier Condition?

    I'm confused.

  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

    Hello @DamoB 

    I have created this flow and it is working:

    2020-03-12 09_48_47-Window.png

     

    So you were right on using "Identifier" field value when using "Get File content" action. I mean, your flow should work! Furthermore, I realized that if there are any folders inside the document library, the flow does not work, and then you should specify the folder in the "Get files (properties only)" action:

    2020-03-12 10_01_05-Window.png

    Hope it helps!

    Ferran

  • Verified answer
    v-bacao-msft Profile Picture
    on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

     

    Hi @DamoB ,

     

    You should add one more condition to exclude folders.

    Please refer to the following method to achieve your requirement.

    128.PNG

    Besides, it seems that you move the file in the same library, maybe it will cause some error.

    Please take a try first and feel free to let us know if you have any questions.

     

    Best Regards,

  • DamoB Profile Picture
    on at
    Re: Move file between Sharepoint folders if older than 30 days AND filename contains

    This was really helpful, I hadn't realised that a folder in library would cause a problem. 

    I have now specified that it should just look for files within General and ignore folders. 

    With this knowledge and the help from @v-bacao-msft on adding the 'XYZ' string the flow now runs!

     

    Thank you @fchopo and @v-bacao-msft .

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 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard