Find Filter Not Working

I am using CTRL + F to open up a find window and I'm basically looking for empty folders by selecting two filters. First is to find items of kind - Folder. Then, the second filter is to find "number of items" to be "less than" + "1". (I also tried this with "equals" + "0" and same results). The folders that it returns in the results for the most part have files and other folders in them. And when I click on them, it displays the item count at the bottom which clearly is not "less than 1". So something is not accounting correctly.


I'm am on Big Sur 11.2.3. I have a 2017 15" MacBook Pro, i7(QC), 16GB RAM, and I'm searching a Samsung T7 Touch 2TB SSD. I loaded 160k pictures on there (about 1.2TB) and ran some duplication software across them and deleted 20GB of pictures. But now the folders that are empty I want to clean up. And I'm getting bad results from the Find function.


Help?

MacBook Pro 15″, macOS 11.2

Posted on Apr 21, 2021 1:14 AM

Reply
Question marked as Top-ranking reply

Posted on Apr 21, 2021 4:52 AM

That search criteria is based on the kMDItemFSNodeCount metadata.

As far as I can tell, it doesn't seem to get updated often, if at all.


The find command in Terminal can show you empty folders, but there are quite a few of them in my home. You might want to have it start searching in the top level of where the folders are stored.

find ~/ -type f -empty

You can modify the find command to delete those found items, but as it returns many more folders than you probably would like to delete, I don't think it is advisable.


Update: I forced Spotlight to reindex my home folder and it appears the metadata was updated.

You could try adding the top-level folder to Spotlight Privacy tab, then remove it. Wait a while (5 minutes, maybe) for it to update the index and try again.

Similar questions

10 replies
Question marked as Top-ranking reply

Apr 21, 2021 4:52 AM in response to iMarkStone

That search criteria is based on the kMDItemFSNodeCount metadata.

As far as I can tell, it doesn't seem to get updated often, if at all.


The find command in Terminal can show you empty folders, but there are quite a few of them in my home. You might want to have it start searching in the top level of where the folders are stored.

find ~/ -type f -empty

You can modify the find command to delete those found items, but as it returns many more folders than you probably would like to delete, I don't think it is advisable.


Update: I forced Spotlight to reindex my home folder and it appears the metadata was updated.

You could try adding the top-level folder to Spotlight Privacy tab, then remove it. Wait a while (5 minutes, maybe) for it to update the index and try again.

Apr 21, 2021 5:27 AM in response to iMarkStone

I have created two empty folders on my Desktop named Xray and Zed. I can find both with the following construct:



I know that an empty folder has a zero node count, and its kMDItemFSSize is reported as (null), so I leave the file size above empty to represent null. I have clicked in and out of the folder a couple of times hoping that the Finder would deposit the hidden .DS_Store file there and determine how that affects the search. So far, over 10 minutes it has not done that.

Apr 21, 2021 12:45 PM in response to iMarkStone

One of the overlooked issues with using the Finder to detect empty folders is that even if there are currently no user files in a given folder, it is very likely that the Finder has placed a hidden Apple Desktop Services Store (.DS_Store) file in the folder. Thus, a folder (unless just created in UNIX) will rarely be found as truly empty. Neither Spotlight, the Finder's Find command, or even the command-line find -type d -empty syntax will report an empty folder when it contains a .DS_Store file.


If you want to report a folder empty that contains one of these .DS_Store files, it will have to be done programmatically. That is about 8 lines of code.



Apr 21, 2021 7:17 AM in response to Barney-15E

I tried two processes. First, I added just a level above the folder I knew had all the empty folders (as a test) and added the folder to the privacy tab and then removed it. No activity on the drive after I did that and all the non-empty folders still remained in the search results.


I then tried your specific instructions and went to the top level on that drive of where I knew the folders were located and it included many of the non-empty folders that were returning in the results and nothing changed again. Both tests, adding multiple folders from the hierarchy, one lower, one at the top, netted no change in the results.



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Find Filter Not Working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.