### vim:ft=zsh:foldmethod=marker
### Take files and directories.
### Print the filenames if they match certain extensions and print
### files from directories recursively matching that extension.
###
### Frank Terbeck <ft@bewatermyfriend.org>
### Last-Modified: Sun Aug 9 14:26:57 2009
###
### URI: <http://ft.bewatermyfriend.org/comp/zsh.html>
###
emulate -L zsh
setopt extendedglob
setopt nullglob
setopt noksharrays
for fd in "$@"; do
if [[ -d $fd ]]; then
print -l -- $fd/**/*.(#i)(flac|ogg|mp3)
elif [[ -f $fd ]]; then
if [[ $fd == *.(#i)(flac|ogg|mp3) ]] ; then
print $fd
else
printf \''%s'\'' does not match *.(#i)(flac|ogg|mp3), Skipping.\n' $fd >&2
fi
else
printf \''%s'\'' is neither file nor directory. Cannot handle.\n' $fd >&2
fi
done