m3u-radio-music-playlists/stuff/merged.sh
U-DESKTOP-3VIS1T9\junguler 70fcbd8b78 add missing header to files
2023-08-01 04:03:52 +03:30

16 lines
646 B
Bash
Executable File

#!/bin/bash
# combine all files
for i in $(find . -type f -name "*.m3u") ; do (cat "${i}"; echo) | grep -v "#EXTM3U" >> $(basename $i) ; done
# convert all file names to lower case
for F in * ; do NEWNAME=$(echo "$F" | tr '[:upper:]' '[:lower:]') ; mv "$F" "$NEWNAME" ; done
# put all files into folders starting with the first character in their names
for i in *.m3u ; do dir=$(echo $i | cut -c 1 -) ; mkdir -p $dir ; mv $i $dir ; done
# add back "#EXTM3U" to files
for i in $(find . -type f -name "*.m3u") ; do sed -i '1s/^/#EXTM3U\n/' $i ; done
# remove empty lines
for i in $(find . -type f -name "*.m3u") ; do sed -i '/^$/d' $i ; done