Music_to_USB.sh

USB Player The other day did a stuff under C# to copy a playlist to a USB, since I use something like this to listen to music in the car.

But since these days I’m a little away from Windows, I did it for bash, its kinda simple but if you need it its faster than the files one by one 😉

#!/bin/bash
if [ -z $1 ] && [ -z $2]; then
echo “Usage: $0 m3u_file target_path”
exit
fi
cat $1| grep -v # > music.txt
declare -i n=`wc -l music.txt | awk ‘{print $1}’`
c=1
while [ $c -le $n ]
do
cp “`head -n$c music.txt |tail -1`” $2
echo “Copying $c of $n”
(( c++ ))
done

Super-easy basically it takes the file .m3u goes through all the paths for each music file, and copy them to the path of your USB Device.

./m.sh ~/Desktop/m.m3u /run/media/betanzos/BETAUSB/