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.
Solved! Go to Solution.
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.
1. Add a Get Files (properties only action). Configure it to use your specific folder. Make sure you also use the sort ID asc.
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}']
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.
1. Add a Get Files (properties only action). Configure it to use your specific folder. Make sure you also use the sort ID asc.
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}']
Thanks for your help. This works 🙂
Z
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
8 | |
2 | |
2 | |
1 | |
1 |