Тёмный

PowerAutomate - Get all empty folders from SharePoint library and delete them 

Markus Schiller
Подписаться 410
Просмотров 5 тыс.
50% 1

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 38   
@ellyagold9987
@ellyagold9987 5 месяцев назад
Really helpful video, thanks for putting that together. If the empty folder is a Channel folder, it will error out, but this can be added in the error handling. Also, you'll need to run this a few times to delete all subfolders as you may have empty folders within empty folders, so the parent folder will get missed on the first run etc.
@MarkusSchiller
@MarkusSchiller 5 месяцев назад
Hi! Thank you and you're absolutely right, it would need some more error handling. You could also put this into a "Do until" loop, until it doesn't find any empty folders anymore, but I think it's a good start.
@AwesomeAbdul4q
@AwesomeAbdul4q Год назад
Thanks for the this wonderful video, it's really helpful
@j.p.7548
@j.p.7548 7 месяцев назад
Hi Markus, thank you for providing this tutorial as it has been very helpful. Quick question when you can.....I've run it on my Microsoft tenant and it does seem to capture all empty folders. Are there any limitations with "how deep" the search runs etc? I am sure we exceed as we pretty much use our sites as a file server. Thank you!!!
@MarkusSchiller
@MarkusSchiller 7 месяцев назад
I'm happy that it works for you. In my production and also test environments, I've never tested it with "very" deep nested structures. Maybe a maximum of five nested folders, so I could not say what is the maximum here
@AbbyRani
@AbbyRani 2 года назад
Thanks 😊
@irisespineandjoint
@irisespineandjoint Год назад
Thank you so much for your video, they have been extremely helpful to us! I just had a quick question regarding the 5,000 limit threshold, would I try and combine your do until video with this one? My only concern is understanding how the filter queries differ in the 2 videos, if I were to try and add a do until action to this would I use ID gt idnumber or FSObjType eq 1
@MarkusSchiller
@MarkusSchiller Год назад
Hi! Yes, you can definitely combine these two but FSObjType only differs between wether the item is a file or a folder, so you have to use the id number as your second reference point. Let's say your first do until loop contains the query "FSObjType eq 1 and itemid gt 0" and it gives you back 4999 items. Then your second loop should contain the query "FSObjType eq 1 and itemid gt 4999" and so on...
@irisespineandjoint
@irisespineandjoint Год назад
@@MarkusSchiller Oh wow so let's say I have 100,000 files I need it to go through, you're saying I would have to create 20 do until loops?
@MarkusSchiller
@MarkusSchiller Год назад
Actually it's just one do until loop, that repeats itself as long as a certain condition is not met. Let's say you have a variable that you use for your itemid. Before the loop the value of this variable is 0. At the end of the loop the variable is set to the maximum itemid that has been found in this iteration. The new value of this variable will be the starting point for the loops next iteration query. For this to work you'll need at least three variables. One for the itemid, that gets bigger with each loop. A second variable for the array, where the result of your query will be appended with each loop. And a third "control variable". Let's say in the last loop, your query will return an empty result, then this control variable should get another value that breaks the do until loop and continues with the rest of your power automate flow. In the do until configuration you can also define the maximum number of loops this action can do. I did one test with about 40.000 items (so the do until looped itself for about 8 times) and it was no problem. Please consider, that if you have a lot of data and a huge amount of items that it can exceed the maximum data one variable can hold. But you will have to try out if that's the case in your situation.
@irisespineandjoint
@irisespineandjoint Год назад
@@MarkusSchiller Sounds good thank you, one more question, what's you opinion on going into the settings of the get file properties and updating the pagination threshold to 100,000, would that also achieve a similar result?
@MarkusSchiller
@MarkusSchiller Год назад
Theoretically yes, but you'll have to be careful with the amount of data. You will have to limit the columns, otherwise it will be way too much to handle. The system has a limit of about 20MB of data threshold for that action and that can be reached very quickly, if you don't limit the columns. Also take in consideration, that you can't use more than 100.000 items in a for each loop, if you want to use this array in another loop. Power Automate is a very useful tool, but it has its limits with large amount of data and that's why we have to create some workarounds sometimes.
@BryanMendez120
@BryanMendez120 4 месяца назад
Hi Markus, If I have a total number of Empty folders grater than 50k then, Does it still works? if no, then How can I delete large number of empty Folders? Thanks
@MarkusSchiller
@MarkusSchiller 4 месяца назад
Hi! You can try this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pj9rjKqdepo.html
@JoseManuelDiazFranco
@JoseManuelDiazFranco Год назад
I need to do the same but with folders in my network and in my local drives, how can I do that? Thanks!
@jjsequf
@jjsequf 5 месяцев назад
Hello Markus, what can I do if I need to delete all the folders and files within a SharePoint library? The flow of the video works with empty folders, but what can I do if I want to delete all the content, empty folders, folders with files, folders with subfolders, and files?
@MarkusSchiller
@MarkusSchiller 5 месяцев назад
Hi! Do you need this to be automated? If not, then simply select all folders via the browser from the root directory of the library and delete them. If you need it automated, you can simply use the "Get files (properties only)" action and then use the "Delete file" action to delete each file/folder. PowerAutomate should make an "Apply to each" around it automatically. If you have more than 5000 items in your library, then you'll either need to let the flow run multiple times, or combine this with another video I've made for arrays / actions that have more than 5000 items: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-O3D2F62DuRk.html
@jjsequf
@jjsequf 5 месяцев назад
@@MarkusSchiller i need it automated
@rajkamalpasunuri551
@rajkamalpasunuri551 Год назад
how can we delete the folder that have the files and not modified for past 180 days
@sharonpanchoo3903
@sharonpanchoo3903 7 месяцев назад
Hi Markus, the flow is executing for me, but not working properly. I have it search the Documents library which has thousands of folders (and dozens of empty folders) but it only recognizes two folders as empty. I tried to adapt the flow by adding a parameter in the Get files (properties only) so that the flow checks only a test folder I set up. Again, the flow executes, but it can't catch any of the folders inside my test folder as empty. The compose input and output only generates "1". The Apply to each step is greyed out, which seems to mean it didn't grab any folders as empty. Do you have any thoughts? Is there another way to check the folders as empty? (Maybe checking if it has 0 bytes?) Any help is greatly appreciated!
@MarkusSchiller
@MarkusSchiller 7 месяцев назад
Hi! You have said, that there are thousands of folders and possibly dozens of empty ones in your document library. First, in the "Get files (properties only)" action, how many items does it return? If it's only 100 then you'll have to increase the Top Count and if you expect more than 5000, then you'll have to add the pagination in the settings of this action. Sadly an apply to each action can only handle 5000 items, so you would need to encapsulate it in a Do until loop and with some helper variables, to get more into your final array. I know it would be way easier if you could look at the file size, but sadly the Get Files action does not provide this data, that's why it's a quite complicated workaround
@sharonpanchoo3903
@sharonpanchoo3903 7 месяцев назад
@@MarkusSchiller Ah okay, thanks for the info. Right now it's only returning 2 empty folders. My intent is to not scan/delete the entire Documents library at once, but to do it in sections. I'm just trying to test the flow. Hence why I create an adapted flow that just scans a much smaller folder (with only a few empty folders, just for testing). This one returns nothing, even though there are a few empty folders. Is there a way to share my flow, or an image of it?
@MarkusSchiller
@MarkusSchiller 7 месяцев назад
@@sharonpanchoo3903 I see, I don't think that there's a direct way here on RU-vid to share pictures. You can contact me on my Facebook channel facebook.com/schillerphotography or if you have any other idea let me know
@sharonpanchoo3903
@sharonpanchoo3903 7 месяцев назад
@@MarkusSchiller Perfect. I reached out to you there.
@MarkusSchiller
@MarkusSchiller 7 месяцев назад
@@sharonpanchoo3903 thank you! I guess Facebook has a lot of trouble now and I can't read any messages. I hope they can fix that soon :-)
@fgs3207
@fgs3207 Год назад
Hey Markus, can you make one video on how to select all subfolders in the library based on their name? Im trying to get it done but ive tried everything. Thank you.
@MarkusSchiller
@MarkusSchiller Год назад
Hi Fabricio, there won't be a video necessary. The query to get all folders is "FSObjType eq 1" and if you want to get results for folders with a certain name, you simply change it to the following: " FSObjType eq 1 and FileLeafRef eq 'my folder name' ".
@fgs3207
@fgs3207 Год назад
@@MarkusSchiller Hey, i will definitely try that. So those two entries go together at the Get Files (Properties only) action?
@MarkusSchiller
@MarkusSchiller Год назад
@@fgs3207 exactly there
@DeniseLindstrom-hv1qm
@DeniseLindstrom-hv1qm 4 месяца назад
This pulls all the folders for me empty or not??
@MarkusSchiller
@MarkusSchiller 4 месяца назад
Hi! If you have created the flow as I did, it should only affect the empty folders.
Далее
САМАЯ ТУПАЯ СМЕРТЬ / ЧЕРНЕЦ
1:04:43
САМАЯ ТУПАЯ СМЕРТЬ / ЧЕРНЕЦ
1:04:43