You are viewing limited content. For full access, please sign in.

Question

Question

Workflow to delete empty folder trees?

asked on June 1, 2015

Hi,

I'm trying to figure out a workflow solution for a client.  They'd like to delete empty branches of a folder tree.  For example, Parent1\Subfolder1 is empty, but Parent1\Subfolder2 has a document in it, so only "Subfolder1" should be deleted.  But in an instance where all the subfolders and sub-subfolders of "Parent2" have no documents in them, they'd like "Parent2" to be deleted.

Does the "Only delete empty folders" option on the "Delete Entry" activity have any depth consideration (documents inside subfolders of current entry), or is it simply: "Does this folder have any children, folders or documents?  If yes, do not delete."

 

Thanks.

0 0

Replies

replied on June 1, 2015

You would have to iterate through the child folders are delete them first. Any folder with subfolders, even empty subfolders, would not be deleted.

0 0
replied on June 1, 2015

I have a workflow doing just what you are talking about. Search the folder tree for all folders. For each entry, do a decision. If data entry count = 0 then delete entry. I have this running on a daily basis so if the parent folder and child folders are all empty the child folders will be deleted and the following day the parent folder will be deleted. I could set up the schedule to run and then run one more time to where the Parent and child folders would be deleted in one day.

0 0
replied on June 1, 2015

You can make it faster if you're not using Search and make it invoke itself on the child folders so it takes advantage of Workflow's multi-threaded architecture.

1 0
replied on July 11, 2019

This is very cool! I am trying to use this but can't quite figure out the trigger mechanism for this. What would be the starting entry? The top level folder of my repository to do a full empty folder cleanup.

0 0
replied on July 11, 2019

If you just want regular cleanup, I would set it to start in the root folder and put it on a monthly schedule.

If your folder paths are more than 32 levels deep, you may need to do a bit more work because Workflow has a limit on how many times a workflow can recursively invoke another one. But 32 levels of subfolders is hopefully unlikely for anybody.

0 0
replied on July 11, 2019 Show version history

I tried starting this on the root folder and it wasn't good. In chat queue with support to remedy runaway workflow without start rule. UGH.

Case 203043 Still awaiting resolution. Client Workflow is down. I am in chat "waiting for Operator".

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.