1

I get this result:

 user@10 $  mdfind kind:application -name "Seashore" -onlyin /Volumes/WD\ Elements
/Volumes/WD Elements/backup 2018/Desktop/Seashore.app
/Volumes/WD Elements/backup Juli 2021/Desktop/Seashore.app
/Volumes/WD Elements/Backup 2020 Aug/Desktop/Seashore.app

But then I get this:

user@10 $ mdfind kind:application -name "*shore" -onlyin /Volumes/WD\ Elements  
 user@10 $

I tried with different wildcards and need help. Is it possible to to search for text in the middle of a name?

1
  • What feels odd to me is that mdfind assumes wildcards… but only as "begins with" rather than "contains". -name "Micro" returns all the Microsoft apps, but -name "soft" doesn't.
    – Tetsujin
    Mar 27, 2022 at 14:49

1 Answer 1

1

The -name shortcut is for exact searches only (at least according to the man page of a tool where the documentation isn’t always correct), so you’re telling it to look for names with literal * in them. Instead, you want to use the kMDItemDisplayName or kMDItemFSName fields. You can learn what these are with the mdls command to list one of the Applications you wish to find later with your excellent test example.

mdfind "kMDItemDisplayName == '*shore*'"
2
  • Also, my brain works better with the “ == “ syntax as opposed to the also valid (( = )) syntax.
    – bmike
    Mar 27, 2022 at 19:10
  • 1
    Ah yes, thank you @bmike! I'v tried playing around with the kMD options, but couldn't get myself to get them to work, but your answer worked. Thank you so much! I am planning on start using mdfind instead of Spotlight for files. Thanks again! Mar 27, 2022 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .