MEDIA="/var/cache/media/noise"
PLAYLISTS="$MEDIA/playlists"
+# Process
+function playlist_check {
+ local cwd="`pwd`"
+
+ cd $MEDIA
+
+ cat $PLAYLISTS/$PLAYLIST.m3u | while read file; do
+ #if [ ! -e "$file" ]; then
+ if ! ls "$file" &> /dev/null; then
+ echo "$PLAYLIST: missing file: $file"
+ fi
+ done
+
+ cd $cwd
+}
+
# Basic syntax
-if [ -z "$PLAYLIST" ]; then
+if [ "$PLAYLIST" == "--help" ]; then
echo "Usage: $BASENAME <playlist>"
if [ -d "$PLAYLISTS" ]; then
fi
exit 1
+elif [ -z "$PLAYLIST" ]; then
+ for playlist in $PLAYLISTS/*m3u; do
+ PLAYLIST="`basename $playlist .m3u`"
+ playlist_check
+ done
+
elif [ ! -f "$PLAYLISTS/$PLAYLIST.m3u" ]; then
echo "No such playlist $PLAYLISTS/$PLAYLIST.m3u"
exit 1
+else
+ playlist_check
fi
-
-# Prepare
-cd $MEDIA
-
-# Process
-cat $PLAYLISTS/$PLAYLIST.m3u | while read file; do
- if [ ! -e "$file" ]; then
- echo "missing file: $file"
- fi
-done