Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to create a Smart Folder which just lists all files of my ~/Music directory - i.e. just a flattened version of that folder.

How can I do this?

(I tried to type * in the search field, but that doesn't list all files.)

share|improve this question
    
Are you looking for all files? Or just music/audio/video files? Do you want to exclude folders? –  jmk Feb 17 '13 at 23:44

4 Answers 4

up vote 11 down vote accepted
+50

By default, the Spotlight GUI in the Finder will not let you use wildcards or other advanced syntax. However, by using the Raw Query search criterion, you can use all the syntax available to the command-line mdfind utility:

  • Navigate to your ~/Music folder
  • Hit ⌘ F
  • Double-check the Scope Bar of the search to make sure Spotlight is just searching your Music folder
  • Hit the "+" button to add a search criterion
  • From the criteria drop-down menu, check if the Raw Query criterion is visible (it isn't by default). If not, click Other... and a criteria list will appear. Search for the Raw Query criterion, check the box to include it in the menu, and click "OK".
  • Select the newly-visible Raw Query criterion and enter the following:

    (kMDItemFSName == '*.mp3') || (kMDItemFSName == '*.ogg') || (kMDItemFSName == '*.flac')
    

The above query will search for files that have .mp3, .ogg, or .flac in their filename (as opposed to the contents of the file). This Macworld article helped me construct this particular query, but this Apple Developer page has a more comprehensive listing of the types of metadata available for raw queries.


Alternatively, you can construct the desired query visually:

Spotlight query

  • Navigate to your ~/Music folder
  • Hit ⌘ F
  • Double-check the Scope Bar of the search to make sure Spotlight is just searching your Music folder
  • Hit the "+" button to add a search criterion
  • Choose the Kind criterion and set it to Any
  • Hold down the Option/Alt key to create a conditional (thanks to Adam Franco for pointing this out) and set it to Any
  • From the criteria drop-down menu, check if the File extension criterion is visible. If not, click Other... and a criteria list will appear. Search for the File extension criterion, check the box to include it in the menu, and click "OK".
  • Add as many File extension criteria as you wish.

If you want the search to display all files below a given folder (regardless of file type), you can use the File visibility criterion:

  • Navigate to your ~/Music folder
  • Hit ⌘ F
  • Double-check the Scope Bar of the search to make sure Spotlight is just searching your Music folder
  • Hit the "+" button to add a search criterion
  • From the criteria drop-down menu, check if the File visibility criterion is visible (it isn't by default). If not, click Other... and a criteria list will appear. Search for the File invisible criterion, check the box to include it in the menu, and click "OK".
  • The File visibility option should now be in the search criterion drop-down menu. So long as this criterion is set to "Visible or Invisible", all files below the present folder will be shown (you can optionally change this to "Visible Items" you don't want dot-files in the results)
share|improve this answer
    
Can you explain why you chose "File visibility"? –  Albert Feb 18 '13 at 12:55
    
Does it need at least one criteria or why did you add any? Why is that? Also, I thought about that and I tried with "URL" and just set it to "contains /" but it didn't worked. –  Albert Feb 18 '13 at 13:01
    
Also, I guess placemarkers like * are not allowed? –  Albert Feb 18 '13 at 13:02
    
How would I modify that if I would want to list exactly all *.{mp3,ogg,flac} files? –  Albert Feb 18 '13 at 13:04
    
I chose the "File Visibility" criterion because it will display search results without entering text in the primary search field. Some criteria behave this way while others don't; this one seemed to be the quickest way to get all of the files listed below a given folder. –  royfactorial Feb 18 '13 at 16:14

It looks like just typing a . in the search field shows all files, but not folders.

share|improve this answer
    
Probably not the files which have no . in its name (i.e. no file extension). And probably it shows also the folders which have a . in its name. –  Albert Feb 19 '13 at 15:12
    
Did you try it? I see files that don't contain periods, and I see no folders. –  Kirk McElhearn Feb 20 '13 at 7:33

I know you want a smart folder, but in the absence of that, you can use Terminal:

ls -R ~/Music

This will give you a list, but I think what you want is to be able to see the files and access them directly.

share|improve this answer
    
And also sort them in varios ways - just everything what Finder can do in a single normal folder. –  Albert Feb 20 '13 at 21:21

Am I missing something, but this seems really simple:

  • Navigate to your ~/Music folder
  • Hit ⌘F
  • Set to Kind is Music
  • Click Save on the top right and you should be good to go.

enter image description here


UPDATE: Here's v2 where I just set it to File Size is greater than 0KB and get all files in the Music folder enter image description here

share|improve this answer
    
Kind is Music doesn't cover all music files for me (e.g. I think it's missing flac and ogg - see my other question) - anyway, in my question, I didn't specifically asked just for music files (whereby of course this was an interesting addition) but just for all files (as this might as well be interesting for other directories and ~/Music was mostly just an example). –  Albert Feb 19 '13 at 19:07
    
Change it to File Size is greater than 0KB and you get every file –  SWL Feb 20 '13 at 13:06
    
Except the files which are empty? –  Albert Feb 20 '13 at 21:20
    
What files are empty? Even .DS_store has a size right? –  SWL Feb 21 '13 at 22:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.