Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2016, 04:35 PM
Stoid Stoid is offline
Guest
 
Join Date: Jun 1999
Location: City of Angels
Posts: 14,849
Mac search- any means of "folders that contain"? Also: template searches?

That's it: with 3rd party or within Spotlight, is there any means of searching for, as an example, "folders that contain mp3s but do not contain PDFs or MP4s".

I am very familiar with the way to structure searches that DO this but NOT that (If anyone reading this does not know how to do this: when you go to click on the + sign that allows additional criteria for a search, hold down the option key, it will turn to ellipses and give you more advanced options...)

The tricky bit is specifying returned results (folders) based on the characteristics of the files the folders contain.

(Not to be pessimistic, but I've been a Mac geek for 30 years, and such a digital hoarder that super-specific searching has always been my thing, and I'v never figured this one out. So I'm anticipating crickets. Hope not, tho...)

Also: regarding "smart" searches. Again, because of my insane search needs and my insane digital hoarding, I find myself having to structure multi-step searches. I would love to be able to save them as templates, meaning without any key data being searched for, just the various options for inclusion and exclusion preserved. Haven't figured out how to make that happen, so I'm stuck with creating a search that has the data plugged in, and I just have to change it, but that can be surprisingly annoying. So if anyone has the secret...assuming one exists.

And finally: I have Houdahspot, which is pretty bitchen for refining searches and getting more data, so if someone knows how to do what I want with that....
Advertisements  
  #2  
Old 03-29-2016, 10:09 PM
Green Bean Green Bean is offline
Guest
 
Join Date: Mar 2000
Location: NJ, Exit #137
Posts: 11,841
Pop your file list into Excel and use functions/filters/conditional formatting to find what you're looking for. Make macros as needed.

That assumes you know how to use Excel.
  #3  
Old 03-29-2016, 10:35 PM
Francis Vaughan Francis Vaughan is offline
Member
 
Join Date: Sep 2009
Location: Adelaide, Australia
Posts: 4,550
Given OS-X is a Unix system, you can quite reasonably use the Unix tools to do this.

The find command gets you a very long way towards what you want. Assuming the file name extensions are used.

You do of course need to be happy using the command line. But you can achieve an enormous amount with not a lot of effort. Add the commands like uniq and awk*, and you can perform wonders.

* OK, awk is not exactly for the faint hearted.
  #4  
Old 03-29-2016, 11:15 PM
coremelt coremelt is offline
Guest
 
Join Date: Jan 2009
Posts: 5,642
Also looks like this might be the sort of thing you are looking for:
http://www.cdfinder.de/
  #5  
Old 03-29-2016, 11:33 PM
markn+ markn+ is online now
Guest
 
Join Date: Feb 2015
Posts: 1,045
Actually "find" isn't particularly well suited to detecting whether a directory contains certain types of files, but here's one rather verbose way to do what the OP wants:

find . -type d | while read d; do if [ "`echo $d/*.mp3`" != "$d/*.mp3" -a "`echo $d/*.mp4`" = "$d/*.mp4" -a "`echo $d/*.pdf`" = "$d/*.pdf" ]; then echo $d; fi; done

--Mark
  #6  
Old 03-30-2016, 01:41 AM
Stoid Stoid is offline
Guest
 
Join Date: Jun 1999
Location: City of Angels
Posts: 14,849
Quote:
Originally Posted by Green Bean View Post
Pop your file list into Excel and use functions/filters/conditional formatting to find what you're looking for. Make macros as needed.

That assumes you know how to use Excel.

I'm not an Excel wizard, but I can make my way around a few things beyond the the basics. How I would use Excel to find folders that contain X but not Y stumps me completely... and I think the problem is the popping of my file list into Excel... there is no file list...at least not initially... are you saying there is a kind of starting search I could do that could then be further refined within an Excel spreadsheet? I would love to know how that works, just for the education of it because I can't begin to guess and it fascinates me to learn new unexpected stuff. IN a practical sense that wouldn't meet my need because it's too much just for file searching.
  #7  
Old 03-31-2016, 09:32 AM
biqu biqu is offline
Guest
 
Join Date: Jun 2003
Location: ubiquitous
Posts: 820
Quote:
Originally Posted by markn+ View Post
Actually "find" isn't particularly well suited to detecting whether a directory contains certain types of files, but here's one rather verbose way to do what the OP wants:

find . -type d | while read d; do if [ "`echo $d/*.mp3`" != "$d/*.mp3" -a "`echo $d/*.mp4`" = "$d/*.mp4" -a "`echo $d/*.pdf`" = "$d/*.pdf" ]; then echo $d; fi; done
Why not use find to search for the "mp3", "mp4", and "pdf" extensions directly, and then pipe the results to "dirname" to get the directory?

Code:
find . -name "*.mp3" -exec dirname {} +

Last edited by biqu; 03-31-2016 at 09:35 AM. Reason: (added command line example)
  #8  
Old 03-31-2016, 12:02 PM
biqu biqu is offline
Guest
 
Join Date: Jun 2003
Location: ubiquitous
Posts: 820
Quote:
Originally Posted by biqu View Post
Code:
find . -name "*.mp3" -exec dirname {} +
This command only does the first part of what the OP asks. To eliminate the directories that also contain PDFs or MP4s, save the results of analogous commands to text files and then compute the set difference:

Code:
find . -name "*.mp3" -exec dirname {} + > dirs-with-mp3s
find . -name "*.mp4" -exec dirname {} + > dirs-with-mp4s
find . -name "*.pdf" -exec dirname {} + > dirs-with-pdfs
cat dirs-with-mp3s dirs-with-mp4s dirs-with-mp4s | sort | uniq -u > first-elimination
cat first-elimination dirs-with-pdfs dirs-with-pdfs | sort | uniq -u
  #9  
Old 03-31-2016, 12:41 PM
biqu biqu is offline
Guest
 
Join Date: Jun 2003
Location: ubiquitous
Posts: 820
Quote:
Originally Posted by biqu View Post
save the results of analogous commands to text files and then compute the set difference:
In order to use the set difference, the text files in question should actually be sets, so we first have to eliminate duplicates from each find command. While we're at it, make the find command case-insensitive.

Code:
find . -iname "*.mp3" -exec dirname {} + | uniq > dirs-with-mp3s
find . -iname "*.mp4" -exec dirname {} + | uniq > dirs-with-mp4s
find . -iname "*.pdf" -exec dirname {} + | uniq > dirs-with-pdfs
cat dirs-with-mp3s dirs-with-mp4s dirs-with-mp4s | sort | uniq -u > first-elimination
cat first-elimination dirs-with-pdfs dirs-with-pdfs | sort | uniq -u
Disclaimer: I haven't yet tested the script on an OS X Terminal, but in GNU/Linux it works as advertised.
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:23 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.

Send questions for Cecil Adams to: cecil@chicagoreader.com

Send comments about this website to: webmaster@straightdope.com

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Publishers - interested in subscribing to the Straight Dope?
Write to: sdsubscriptions@chicagoreader.com.

Copyright 2017 Sun-Times Media, LLC.

 
Copyright © 2017