How to find files not of a certain type

command linefind

I'm trying to find out all of the different types of files in my unorganized music folder. I've been trying this command (to list files of types besides the ones I know are in there):

find zUnorganized/ -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" -or -not -iname "*.m4a" -and -not -iname "*.jpg"

But it's not working. How would I get that command work? Is there a way to do it using -regex?

Thanks!

Best Answer

You wrote (redundant parentheses added for clarity):

find zUnorganized/ \( -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" \) \
               -or \( -not -iname "*.m4a" -and -not -iname "*.jpg" \)

Either use -and -not throughout, or use or throughout and finish with -print (meaning: do nothing for this, otherwise do nothing for that, etc, otherwise print). You'll also want to limit the search to regular files, otherwise directories will be listed.

find zUnorganized/ -type f -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" -and -not -iname "*.m4a" -and -not -iname "*.jpg"
find zUnorganized/ \! -type f -o \
                   -iname "*.mp3" -o -iname "*.flac" -o -iname "*.MP3" -o -iname "*.wav" -o -iname "*.m4a" -o -iname "*.jpg" -o \
                   -print