Using of mfind in general case : with or without extension for substring of a filename, even with a number
I try to use mdfind to find files from a part (substring) of their filename which can be also a number.
For example, I have a file called 'GCph_WL_FoM_154.46_AND_SIMPLE_SUM_GCsp_XC_AVEC_NO-ZCUT_FoM_571.35.py
'.
If I do :
mdfind '154.46'
or
mdfind -name '154.46'
or
mdfind 'kMDItemFSName == "154.46"'
There are not results for these different commands.
I would like to find all the files whose filenames (with or without extension) contains a substring as argument and without case sensitive, and mostly, working also with number for the substring (number could also be located at the end of filename).
Could anyone tell me how could I achieve this ?
UPDATE 1 : I have followed the procedure of reindexing posted on this link.
1) How can I identify the processes launched by the terminal command :
$ sudo mdutil -i on "/Volumes/Macintosh HD"
Moreover, unlike to what is indicated on this link, I didn't find .Spotlight-V100
file into "/Volumes/Macintosh HD"
directory. I found it into /System/Volumes/Data/
directory : is it normal ? (I am on Catalina 10.15.3). I have deleted it.
2) Still about this reindexing, is there a way to get a progression bar, graphically or directly inside terminal. Indeed, I remind that I have a 2TB
SSD disk and it seems it takes a very long time to reindex all the "/Volume/Macintosh HD"
. That's why I would like to get this progression bar.
Solution 1:
You are using mdfind
correctly, but apparently there is a problem with your Spotlight indexes.
I attempted to reproduce the behaviour you observed, but it seems to work fine for me. In fact I got exactly the same results as user3439894. First I created a sample file having the same name as your file.
touch GCph_WL_FoM_154.46_AND_SIMPLE_SUM_GCsp_XC_AVEC_NO-ZCUT_FoM_571.35.py
Then I tried two different search commands. Both of them produced exactly one result: the file created above.
mdfind '154.46'
mdfind -name '154.46'
I also tried your third search command, but it yielded nothing because the search term was incorrect. Here it is again, fixed, with *
asterisks for wildcard globbing.
mdfind 'kMDItemFSName == "*154.46*"'
This is the answer to the question you asked originally. If you want a different answer, please edit your post to focus on one question.