How I can list all files of a certain type in a directory?
For example, if I want to see all MP3 files in the current folder, what do I do?
Disregarding suffix, you can use the
file command to identify audio files. That is more complicated than an simple
ls command can do, so one would use a script. For example (ID3 seems to be
file jargon for MP3):
#!/bin/sh for name in "$@" do case $(file "$name") in (*Audio*ID3*) ls -l "$name" ;; esac done
Putting that in your executable path (such as
~/bin as "ls-audio") you could then do
to list details of just the MP3 audio files.
Using OS X spotlight:
mdfind -onlyin /path/to/directory "kMDItemKind == 'MP3 audio'"
You can simply go to the directory that you wish to query by using the
cd command to get to the directory you want to query. Than type in
ls *.mp3 to list all files with the extension of the file you wish to find.
For example if you want to see all
.txt files on your desktop you can simple type
cd ~/Desktop and next type in
ls *.txt which will give you the result of
lists.txt output.txt output2.txt