Finding a file in Terminal

Joined
May 4, 2009
Messages
3
Reaction score
0
Points
1
I left the country for 7 months and when I came back someone had moved some files around on my computer. I am looking for one folder in-particular but for the life of me can't remember the name of it right now. I have tried using finder but had no luck. I know the .extension that it uses and I was wondering if I can search for a file in Terminal by the extension it uses. Anything helps. Thanks for your time!
 
Joined
Sep 24, 2006
Messages
2,766
Reaction score
232
Points
63
Location
Brooklyn, New York
Your Mac's Specs
15" 2014 MacBook Pro, i7 2.5Ghz, 16GB RAM, 512GB SSD; iPad 3, iPhone 6
Have you tried using spotlight?

What kind of file is it? If it's a document, you can use spotlight to search for a keyword within the document.
 
OP
A
Joined
May 4, 2009
Messages
3
Reaction score
0
Points
1
Probably another thing I should have mentioned is that I used LameSecure to lock the folder. It is just a folder with a bunch of music files that I have created in Logic. I can't find the folder in spotlight because I forget the name and I can't search for the contents because LameSecure hides them from spotlight. They aren't hidden in terminal, however, so if I could just figure out how to search for certain extensions on the complete hard drive in terminal I would be in good shape. Thanks for the response!
 
Joined
Sep 24, 2006
Messages
2,766
Reaction score
232
Points
63
Location
Brooklyn, New York
Your Mac's Specs
15" 2014 MacBook Pro, i7 2.5Ghz, 16GB RAM, 512GB SSD; iPad 3, iPhone 6
I only know how to use the mdfind command in the terminal, but AFAIK that uses spotlight technology anyway.

You could try it. Type this:

mdfind "kMDItemFSName = [name]"

replace [name] with the actual partial filename or extension you know

If you know the directory roughly, you could try

mdfind -onlyin [name of directory]
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You can use locate to do the job.

First, update the locate database:
Code:
sudo /usr/libexec/locate.updatedb

Second, use locate to find the files:
Code:
locate *.html
This would search for all html files on your computer. Replace as necessary.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
The find command may be helpful here. Do a 'man find' in the terminal. Near the end are some examples.

To find files with extensions '.mov' from the very top directory down, you would do;

find / -name '*.mov' -print​
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top