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

Condition: Folder in sharepoint is empty

Hi all,

 

I'm currently making a flow, which will delete all items on a library if their modification date is older than 10 years. However I'm struggling with finding a condition, which states that the folder has to be empty in order to be deleted. Any Ideas?

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
SCTdan
Continued Contributor
Continued Contributor

You can use List Folder to get folder contents, or Get Files should work too.  Since that returns an array of items, you can use the length() function to determine if there are any files.

 

Quick example-

 

With no files in the folder-

 

And with one file in the folder, returns False-

 

 

Hopefully that does what you need it to!

View solution in original post

4 REPLIES 4
SCTdan
Continued Contributor
Continued Contributor

You can use List Folder to get folder contents, or Get Files should work too.  Since that returns an array of items, you can use the length() function to determine if there are any files.

 

Quick example-

 

With no files in the folder-

 

And with one file in the folder, returns False-

 

 

Hopefully that does what you need it to!

v-bacao-msft
Community Support
Community Support

Hi @Momo,

 

I think the way SCTdan provides is work for you. Please try it.

In addition, you could also use Get files to get the items first, and then determine whether it is a folder. If so, configure the Id in the List folder action.

Please take a try.

 

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

It works and I learned something new. thank you very much!

Hi @SCTdan thank you for this solution! i was looking for something to show me when a file is in a folder (when i am mid way through a flow) and this works perfectly.

I am trying to add a clause thought.

What I need is to send an email when a file is added (but to a folder that was just created during my flow, so the folder does not exists or has a name till this point - for that reason i cannot start a new flow) is there any way (other than Delay - to do something like "check till there is something in the folder and then send the email - instead of "Do Until" more like a "don't do until" is that even possible? (hope so!) thanks

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (6,676)