2

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.

6
  • On my system I opened Terminal and executed touch GCph_WL_FoM_154.46_AND_SIMPLE_SUM_GCsp_XC_AVEC_NO-ZCUT_FoM_571.35.py and then tried both mdfind '154.46 and mdfind -name '154.46', it found it. I then moved the file to /Users/Shared/ and ran both mdfind commands and it was found. Assuming it's stored on an indexed volume/location it should find it. I'd try rebuilding the index. Mar 8, 2020 at 21:10
  • @user3439894 . Thanks, I decided to rebuild the index with putting/removing my Volume into System Preferences / Spotlight . The process of rebuild seems not to run : ps aux | grep -i spotlight gives : _spotlight 48545 0.0 0.0 4806584 7684 ?? S 11:04PM 0:00.05 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker_shared -s mdworker -c MDSImporterWorker -m com.apple.mdworker.shared
    – user256573
    Mar 8, 2020 at 22:12
  • _spotlight 48544 0.0 0.0 4813752 7804 ?? S 11:04PM 0:00.05 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker_shared -s mdworker -c MDSImporterWorker -m com.apple.mdworker.shared
    – user256573
    Mar 8, 2020 at 22:13
  • _spotlight 48543 0.0 0.0 4832184 7832 ?? S 11:04PM 0:00.06 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker_shared -s mdworker -c MDSImporterWorker -m com.apple.mdworker.shared _spotlight 48542 0.0 0.0 4701112 7824 ?? S 11:04PM 0:00.06 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker_shared -s mdworker -c MDSImporterWorker -m com.apple.mdworker.shared
    – user256573
    Mar 8, 2020 at 22:14
  • Does Smean Sleeping process ? So inactive process, doesn't it ?
    – user256573
    Mar 8, 2020 at 22:15

1 Answer 1

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.

1
  • Thanks for your answer : is there a way to get an insensitive reasearch of the substring "foo" called for example by :' mdfind kMDItemFSName == "*foo*" ?
    – user256573
    Mar 19, 2020 at 10:51

You must log in to answer this question.