# Mac- way to search for folders based on contents?

**URL:** <https://boards.straightdope.com/t/mac-way-to-search-for-folders-based-on-contents/743958>\
**Category:** Factual Questions\
**Created:** [January 23, 2016, 8:26am UTC](https://boards.straightdope.com/t/mac-way-to-search-for-folders-based-on-contents/743958 "2016-01-23T08:26:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/stoid/32/272_2.png) [@Stoid](https://boards.straightdope.com/u/Stoid)\
**Post date:** [January 23, 2016, 8:26am UTC](https://boards.straightdope.com/t/mac-way-to-search-for-folders-based-on-contents/743958/1 "2016-01-23T08:26:56Z")

</div>

For example: find all folders containing videos.

This would really make my life SO much simpler. I don’t think it’s possible as a straight search in Spotlight, but perhaps a script, a different search tool?

---

<div class="post-metadata">

**Author:** ![Stoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/stoid/32/272_2.png) [@Stoid](https://boards.straightdope.com/u/Stoid)\
**Post date:** [January 23, 2016, 8:48am UTC](https://boards.straightdope.com/t/mac-way-to-search-for-folders-based-on-contents/743958/2 "2016-01-23T08:48:18Z")

</div>

It’s searching for directories based on the type of files contained within them- perhaps there is a Unix command which works?

Since it is possible to find empty folders, it seems it must be possible to find folders which are not empty by other criteria…

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [January 23, 2016, 12:15pm UTC](https://boards.straightdope.com/t/mac-way-to-search-for-folders-based-on-contents/743958/3 "2016-01-23T12:15:48Z")

</div>

> [@Stoid](#):
>
> It’s searching for directories based on the type of files contained within them- perhaps there is a Unix command which works?
> 
> Since it is possible to find empty folders, it seems it must be possible to find folders which are not empty by other criteria…

I’m not very good with shell commands, but here’s one way in Unix:  
find / -type d -exec Has\_vid {} ; -print

Replace / with whatever top-level directory in which you want to search. For Has\_vid you need to write a script that tests a directory. I used  
#!/bin/tcsh  
echo $1/\*.{flv,mp3,FLV,MP3,mkv} \>& /dev/null

As you can see it just searches for filenames with any of several specified suffixes (for which I show only a few examples). I’m sure there’s a way to cram such a command into the _find_ and get a one-liner, but the syntax may get awkward.
