プレイリストファイルを作るスクリプト

新しく買った DAPディレクトリ以下を再生みたいなことができないので…。

#!/bin/bash

set -euC


if [ "$#" -lt 1 ]
then
  echo "$0 <ROOT_DIR> [<MIN_DEPTH>]" 1>&2
  exit 1
fi


PL=all.m3u
root="$1"
mindepth="${2:-1}"

while read -r dir
do
  echo "$dir"
  (
    cd "$dir"
    echo '#EXTM3U' >| "$PL"

    find . -type f \
      -iname '*.mp3' -or \
      -iname '*.m4a' -or \
      -iname '*.ogg' -or \
      -iname '*.wma' \
      | sort \
      >> "$PL"
  )
done < <(find "$root" -mindepth "$mindepth" -type d)