Searching with grep & Spotlight's kMDItemDisplayName
# first a grep regex: # only match the last part of a complete file path mdfind '*==*' | grep -i -E '/[^/]*?somestring[^/]*?[0-5][^/]*?$' | sed 's/ /\\ /g' | xargs basename # let Spotlight search for the fixed part of the search string, and grep for the variable one mdfind 'kMDItemDisplayName == "*somestring*"wc' | grep -i -E '/[^/]*?[0-5][^/]*?$' # To search for folders add: mdfind 'kMDItemKind == "Folder" && kMDItemDisplayName == ...' ... # To search for files you may add, for example: mdfind '( kMDItemKind == "*text*"wc || kMDItemKind == "*document*"wc || kMDItemKind == "*image*"wc ) && kMDItemDisplayName == ...' ... # ... or just ... mdfind 'kMDItemKind != "Folder" && kMDItemDisplayName == ...' ...