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



how to search repository and only return empty folders

asked on January 23, 2014

 is there a way to search for emty folders in my repository to i can keep it clean?

1 0


replied on January 23, 2014

An advanced search of

{LF:Name="*", Type="F"} - {LF:ChildName="*"}

should do what you want (the syntax is find all folders and then subtract out those that have any children).

8 1


replied on January 23, 2014

The workflow below would require WF 9.1, but here is how I would do it:


You get the subfolders of \Raw Images\Processed, check if their last modification date is more than 7 days ago (moving docs in or out of a folder or deleting documents from it will change the folder's last modification date) and then delete the folder with the "only delete if empty" flag on in Delete Entry.


The Date Token Calculator activity is figuring out what 7 days before the current date was and the Conditional Sequence checks the date part of the Last Modified property on the folder:


You can then put this workflow on a daily schedule.


Alternatively (or if you're on WF 9.0.2), you can replace Find Entries with a Search Repository that uses the date token and skip the Conditional Sequence check (since the search will only return folders older than 7 days):


{LF:Name="*", Type="F"} & {LF:Modified<="%(DateTokenCalculator_SevenDaysAgo)"} & {LF:LOOKIN="REPOSITORY\Raw Images\Processed", SUBFOLDERS=0}


4 0
replied on February 5, 2014 Show version history

Okay, so the problem here is you are trying to delete the folders only if they are empty right? Well maybe the folders are not empty till the next step when the contents within are deleted/moved.


Try getting the workflow to repeat itself a second time to clean up the folders after the files are deleted. This should fix the issue you are experiencing. 


If this does not fix things, please post screenshots of the Workflow so we can understand better what it is you are trying to do.

1 0
replied on January 23, 2014

Maybe I need to be more specific.  I have a root folder, raw images, it contains one subfolder called processed.  I'm then running a quickfields session after processing images in, raw images folder, I move them to a \processed\%date Time\.  Then after 7 days i'm doing a clean up of all the folders below processed.  The issue is my repository search, in the client, returns folders and entries but when I copy that search and move it to a workflow it only deletes the entries in each folder below processed but not the the folder.  So i'm left with empty folders below proceessed but I want delete both the entry and the folder.  However I need to keep at least the last 7 days.  So once a file or folder has aged to 8 days i want it purged.


Folder structure


\Raw Images\processed\1/6/2014 3:16:41 PM\all my images .....

\Raw Images\processed\1/7/2014 5:06:41 PM

0 0
replied on August 27, 2014

Just wanted to say thank you for posting this!


I now have a Business Process called "Seek and Destroy" for cleaning up repositories after migration, mostly.  


It uses a search like this:

{LF:Name="*", Type="F"} & {LF:LOOKIN="%(Entry Path)\%(Entry Name)"} - {LF:ChildName="*"}


followed by a for-each loop over a delete entry action.


It actually puts a few messages in the results when it runs - I think the search and the action disagree on whether a folder with just a shortcut in it is "empty" - but it works and is a great little admin tool.

0 0
replied on August 27, 2014 Show version history

Glad this is working for you! I just wanted to add that you can specify entry type for ChildName, depending on whether or not you want a folder with a shortcut (or one with subfolders) to be considered empty.


For example, {LF:Name="*", Type="F"} - {LF:ChildName="*", Type=DFS} will return only folders that have absolutely nothing in them; no documents (D), no subfolders (F),  and no shortcuts (S). By default, the entry type for ChildName is Documents.

2 0
replied on August 15, 2017

Is ChildName the only search criteria you can use Child on?  I need to search for Child Templates or Child Field Values.  Or more specifically, the lack of them.


I tried grouping the LFChildName and Template criteria using (), with & or - but neither of those made that Template Name operate on the child, it still applies it to the LFName criteria.


{LF:Name="*", Type="F"} & {LF:LOOKIN="\Client Files"} & ({LF:ChildName="W*4*"} & {[Client Files]})


{LF:Name="*", Type="F"} & {LF:LOOKIN="\Client Files"} & ({LF:ChildName="W*4*"} - {[Client Files]})


Any ideas?

0 0
replied on August 16, 2017

Is ChildName the only search criteria you can use Child on?

That's correct. We recently added support for searching on the parent template, but not the child template.

It sounds like you're trying to get a list of folders where there are documents that reference W4, but do not have the template name "Client Files". Could you share the reason you want the folders, and not the documents themselves?

To get the list. you could run a search for the documents themselves, then add the Path column. If you use Generate Report/Download Results (name varies depending on version) to get a CSV file, you could then use excel to filter unique results for the Path.

0 0
replied on August 17, 2017

Technically, I'm trying to find folders that do NOT have a document in them that has a W-4 referenced.  My search syntax above is my attempt to get that to come through with what I saw available.

So I need to search an entire directory, and id folders without any documents with a specific template as a direct child.

I know there are dataI can put on the folder fields that would indicate the presence of the template type using workflow and do filters in Excel, but I was really hoping for a straightforward Saved Search in the client.

0 0
replied on August 17, 2017 Show version history

Hm, the first part of your search:

{LF:Name="*", Type="F"} & {LF:LOOKIN="\Client Files"} & {LF:ChildName="W*4*"}

will give you folders that DO have documents with a name that indicates that they are a W-4.

Instead, you should try

{LF:Name="*", Type="F"} & {LF:LOOKIN="\Client Files"} - {LF:ChildName="W*4*"}

I've change the & to a - to indicate "does not include". That will get you all the folders that do not have a document where the name starts with W-4, thought it may return some false positive with the * wildcard.

IF you want the full list of documents that neither have that template nor have that name (to do the workaround in excel):

{LF:Name="*", Type="F"} & {LF:LOOKIN="\Client Files"} - ({LF:Name="W*4*"} | {[Client Files]} )

Here I've used - to exclude all documents that have EITHER the name like W*4* OR the Client Files Templates.

0 0
replied on April 19

I tried to use the advance search syntax as posted.  But my folder has subfolder, follow by another subfolder, then follow by documents.  The syntax returns all folders and didn't subtract the ones that has documents underneath the subfolder.

0 0
replied on April 19

The syntax for "ChildName" only refers to entries directly within the folder. As such, if the document you are using to exclude folders is in a subfolder, the subfolder will be excluded but not the parent folder for that subfolder.

In your example, that means 000000205 would be returned but 000093250 would not be.


It seems like you need a different solution than the one posted above. What are you trying to accomplish with this search, and how often would you need to run it?

For example, "trying to find folders without a memo added so that you can update them once a month".


0 0
replied on April 19

I need to locate the documents underneath the layers of folders, and only documents have metadata fields that I would then used for a lookup and update the metadata fields and move the entry to a new location.  I would then also need to delete the folders and subfolders that no longer have any documents in it.  


0 0
replied on April 19

It sounds like you have two separate steps, both which might be best addressed using workflow:

  1. Locate and update the documents. This should be a straightforward metadata search if the documents themselves have the metadata.
  2. After cleaning up the documents, find and delete empty folders. There are multiple posts on using workflow to delete empty folders, including deleting a whole tree:
    1. talks about deleting empty folders and, when appropriate, parent folders
    2.  talks about deleting folders during a workflow that processes documents within the folder


If you don't want to build a workflow, I'd recommend doing the following:

  1. Searching for and processing the documents you mentioned
  2. Clean folders level by level. That is, run the "empty folders" search, delete those folders, then re-run the search to find any now-empty parent folders.
0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.