Selecting files

Joined
Jan 30, 2008
Messages
11
Reaction score
0
Points
1
Hello,

I would like to search my entire hard drive looking for a specific file type but only if the file does not live in specific folders.

For example, find all the files with an extension of .txt but exclude them if they live in Documents or Downloads or any other folder I specify.

So far I am unable to figure out how to do this with Spotlight. I looked at Automator and I have a trial version of a product called Mac Pilot but I have no experience with them.

How do I select files, excluding certain folders?

Thanks in advance.
Hector
 

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)
The good ol command line is your friend here. Are you familiar with the Terminal application?

Here's how you can do it at the command line (Terminal). This is the command that you want:
Code:
cd ~; find . -not \( -path "<dir name>/*" -prune \) -name \*.<file ext>
Replace <dir name> and <file ext> as needed. Let's look at an example. Let's say that we want to search for all the txt files in your Documents folder but want to exclude the folder called "Workspace." This is what your command would look like:
Code:
cd ~; find . -not \( -path "./Documents/Workspace/*" -prune \) -name \*.txt
 
OP
H
Joined
Jan 30, 2008
Messages
11
Reaction score
0
Points
1
Thanks

Thank you. I am vaguely familiar with Terminal commands so I will try to muddle through with destroying anything.

Isn't the "cd" command the Change Directory command? With the parameters you specified will I see a list of the results without actually changing anything?

Thanks again.
Hector
 

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)
The cd command with the tilde (~) changes the prompt back to your home directory so any paths that you search from have to be from there (I should have mentioned that the first time).

This just find files, nothing more.
 

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