cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DamoB
Frequent Visitor

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

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

1 ACCEPTED SOLUTION

Accepted Solutions

 

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,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
fchopo
Super User
Super User

Hello @DamoB 

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

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
DamoB
Frequent Visitor

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
Frequent Visitor

And the error message:Move files error.PNG

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

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
DamoB
Frequent Visitor

@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.

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

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

 

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,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

DamoB
Frequent Visitor

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 .

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,856)