cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular 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
Highlighted

 

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
Highlighted
Super User II
Super User II

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!
Highlighted
Regular 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

Highlighted
Regular Visitor

And the error message:Move files error.PNG

Highlighted

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!
Highlighted
Regular 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.

Highlighted

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!
Highlighted

 

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

Highlighted
Regular 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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,776)