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

  Рет қаралды 5,738

Markus Schiller

Markus Schiller

Күн бұрын

Пікірлер: 40
@divine-by-zero
@divine-by-zero Ай бұрын
Holy rusted metal, Batman. That was a real life saver. So much cleaner than what I was trying to do - quick as well. Thanks a bunch!
@MarkusSchiller
@MarkusSchiller Ай бұрын
Thank you very much Robin, I've actually made a better version of this flow here: kzbin.info/www/bejne/nnq4k2ejibV4o9k But both work, so enjoy it :-)
@ellyagold9987
@ellyagold9987 7 ай бұрын
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 7 ай бұрын
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.
@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!
@j.p.7548
@j.p.7548 9 ай бұрын
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 9 ай бұрын
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
@BryanMendez120
@BryanMendez120 6 ай бұрын
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 6 ай бұрын
Hi! You can try this video: kzbin.info/www/bejne/ppuco52BpsmYptE
@rajkamalpasunuri551
@rajkamalpasunuri551 2 жыл бұрын
how can we delete the folder that have the files and not modified for past 180 days
@sharonpanchoo3903
@sharonpanchoo3903 9 ай бұрын
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 9 ай бұрын
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 9 ай бұрын
@@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 9 ай бұрын
@@sharonpanchoo3903 I see, I don't think that there's a direct way here on KZbin 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 9 ай бұрын
@@MarkusSchiller Perfect. I reached out to you there.
@MarkusSchiller
@MarkusSchiller 9 ай бұрын
@@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 :-)
@jjsequf
@jjsequf 7 ай бұрын
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 7 ай бұрын
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: kzbin.info/www/bejne/hWSnY3lsZ6moiM0
@jjsequf
@jjsequf 7 ай бұрын
@@MarkusSchiller i need it automated
@AwesomeAbdul4q
@AwesomeAbdul4q 2 жыл бұрын
Thanks for the this wonderful video, it's really helpful
@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.
@DeniseLindstrom-hv1qm
@DeniseLindstrom-hv1qm 6 ай бұрын
This pulls all the folders for me empty or not??
@MarkusSchiller
@MarkusSchiller 6 ай бұрын
Hi! If you have created the flow as I did, it should only affect the empty folders.
@AbbyRani
@AbbyRani 2 жыл бұрын
Thanks 😊
@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
PowerAutomate: Get all empty folders from a document library
8:38
Markus Schiller
Рет қаралды 4,5 М.
PowerAutomate - Get more than 5000 empty folders and delete them V2
20:16
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 21 МЛН
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 9 МЛН
PowerAutomate: Get all folders from SharePoint library
4:46
Markus Schiller
Рет қаралды 19 М.
PowerAutomate - Get more than 5000 empty folders and delete them
10:23
PowerAutomate - Compare arrays with objects
7:46
Markus Schiller
Рет қаралды 1,6 М.
PowerAutomate - Get all folders and add them to an Excel table
7:28
Markus Schiller
Рет қаралды 4,3 М.
PowerAutomate - Merge Excel sheets
14:54
Markus Schiller
Рет қаралды 23 М.
PowerAutomate   Get more than 5000 files or folders into a single array
11:52
PowerAutomate - Create XML files
16:22
Markus Schiller
Рет қаралды 642
PowerAutomate - Change CSV Delimiter 2.0
7:29
Markus Schiller
Рет қаралды 632
PowerAutomate: Get not common items from two arrays
14:42
Markus Schiller
Рет қаралды 6 М.