cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
72Zib
Helper I
Helper I

Keep limited number of files

Hi 

Is there a way to keep limited number of files in SharePoint folder? When new file is created in SharePoint from outlook, I would like to set a limit to 30 files so when 31st file would arrive the oldest would need to be deleted.

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Dual Super User
Dual Super User

Hi @72Zib,

 

Yes, this would be possible by using a Get files action (order it by ID ascending) and count the length of the output. When this equals 31 you could use the identifier of the first item (since it is ordered ascending by ID) and delete that file.

 

Below is an example of that approach.

 

deletefile_limit.png

 

1. Add a Get Files (properties only action). Configure it to use your specific folder. Make sure you also use the sort ID asc.

 

getfiles_propertiesonly.png

 

2. Add a condition with the following expression:

length(outputs('Get_files_(properties_only)')?['body/value'])

 

3. Add a delete file action. Use the following expression to delete the first file.

outputs('Get_files_(properties_only)')?['body/value'][0]['{Identifier}']

 

condition_lenght31.png

View solution in original post

2 REPLIES 2
Expiscornovus
Dual Super User
Dual Super User

Hi @72Zib,

 

Yes, this would be possible by using a Get files action (order it by ID ascending) and count the length of the output. When this equals 31 you could use the identifier of the first item (since it is ordered ascending by ID) and delete that file.

 

Below is an example of that approach.

 

deletefile_limit.png

 

1. Add a Get Files (properties only action). Configure it to use your specific folder. Make sure you also use the sort ID asc.

 

getfiles_propertiesonly.png

 

2. Add a condition with the following expression:

length(outputs('Get_files_(properties_only)')?['body/value'])

 

3. Add a delete file action. Use the following expression to delete the first file.

outputs('Get_files_(properties_only)')?['body/value'][0]['{Identifier}']

 

condition_lenght31.png

Thanks for your help. This works 🙂

Z

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (2,728)