Script m3uToDir.sh

From campisano.org
Jump to navigation Jump to search
#!/bin/bash



###     check
#
if test ! -f "$1" || test ! -d "$2"; then
    echo
    echo "Usage: $0 <file.m3u> <destinationPath>"

    echo
    exit -1;
fi;



M3U="$1"
DEST="$2"

NUM=`grep -v \# "$M3U" -c`;

COUNT=1;

while test $COUNT -lt $NUM; do
    FILE=`grep -v \# "$M3U" | head -$COUNT | tail -1`;
    /bin/cp -v "$FILE" "$DEST";
    let COUNT=$COUNT+1;
done



ls --color -hl "$DEST";



# End