2025.04.30-20:50
This commit is contained in:
22
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_Playlist#01.sh
Executable file
22
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_Playlist#01.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# bash script to create playlist files in music subdirectories
|
||||
#
|
||||
find . -type d |
|
||||
while read subdir
|
||||
do
|
||||
|
||||
if [[ -f ./"$subdir"/"${subdir##*/}.m3u" ]]
|
||||
then
|
||||
echo "File "$subdir"/*.m3u already exists, skipping"
|
||||
else
|
||||
echo would build for $subdir
|
||||
for filename in "$subdir"/*
|
||||
do
|
||||
if [ ${filename: -4} == ".mp3" ] || [ ${filename: -5} == ".flac" ] || [ ${filename: -5} == ".loss" ] || [ ${filename: -5} == ".aiff" ] || [ ${filename: -4} == ".aif" ]
|
||||
then
|
||||
echo "${filename##*/}" >> ./"$subdir"/"${subdir##*/}.m3u"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
91
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_Playlist#02.sh
Executable file
91
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_Playlist#02.sh
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Create m3u8 playlists
|
||||
#
|
||||
# Created by @hasecilu
|
||||
# Based on gists: "Eddy-Barraud/playlist-all.sh" and "scarlson/playlist.sh"
|
||||
#
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
|
||||
v=1 # verbosity, 0/1
|
||||
|
||||
function playlists() {
|
||||
# First argument is the mode (recursive, single)
|
||||
# Second argument is the path of the directory
|
||||
|
||||
cd "$2" || exit
|
||||
[ "$v" -eq 1 ] && echo "${PWD##*/}" | figlet -f small | lolcat
|
||||
|
||||
# Delete old m3u and m3u8 playlists
|
||||
find . -type f -name "*.m3u*" -delete # If "-delete" didn't work use: "-exec rm {} \;"
|
||||
|
||||
# Create new playlists
|
||||
find ~+ -type d | sort |
|
||||
while read -r subdir; do
|
||||
for filename in "$subdir"/*; do
|
||||
if [[ $filename =~ \.(acc|aif|aiff|flac|m4a|mp3|ogg|wav|wma)$ ]]; then
|
||||
if [ "$1" == "-r" ]; then
|
||||
echo "${filename##*/}" >>"$subdir/${subdir##*/}.m3u8"
|
||||
[ "$v" -eq 1 ] && echo -e "${subdir##*/}.m3u8\t\t${filename##*/}" | lolcat
|
||||
elif [ "$1" == "-s" ]; then
|
||||
relative_path=${subdir#"$PWD"} # Remove common path
|
||||
relative_path=${relative_path:1} # Remove leading '/' character
|
||||
[ "$PWD" == "$subdir" ] && slash="" || slash="/"
|
||||
echo "$relative_path$slash${filename##*/}" >>"$PWD/${PWD##*/}.m3u8"
|
||||
[ "$v" -eq 1 ] && echo -e "${PWD##*/}.m3u8\t\t$relative_path$slash${filename##*/}" | lolcat
|
||||
elif [ "$1" == "-cd" ]; then
|
||||
album=$(dirname "$subdir")
|
||||
# Join album and CD directory
|
||||
album_cd=$(basename "$album")/$(basename "$subdir")
|
||||
album_cd=${album_cd//\// } # Replace '/' for space ' '
|
||||
echo "${filename##*/}" >>"$subdir/$album_cd.m3u8"
|
||||
[ "$v" -eq 1 ] && echo -e "$album_cd.m3u8\t\t${filename##*/}" | lolcat
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
function default() {
|
||||
# Create one playlist for every directory that has at least one audio file
|
||||
playlists -r $HOME/Music
|
||||
|
||||
# For specific directories that have several nested directories
|
||||
# create a single playlist that includes all subdirectories
|
||||
playlists -s $HOME/Music/VeryObscureGenre
|
||||
|
||||
# For directory-albums that contains various CDs subdirectories
|
||||
# create one playlist for every CD preserving the album name
|
||||
playlists -cd $HOME/Music/Album
|
||||
}
|
||||
|
||||
function help() {
|
||||
echo -e "\nDescription :"
|
||||
echo -e "\tThis script creates music playlist(s) for a given directory."
|
||||
echo -e "\nArguments :"
|
||||
echo -e "\t-r recursively create playlists"
|
||||
echo -e "\t-s create a single playlist"
|
||||
echo -e "\t-cd recursively create playlists of a album directory that contains CDs as subdirectories"
|
||||
echo -e "\t-h show help"
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# Main code
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
default
|
||||
elif [ $# -eq 2 ]; then
|
||||
if [[ "$1" == "-r" ]]; then
|
||||
playlists -r "$2"
|
||||
elif [[ "$1" == "-s" ]]; then
|
||||
playlists -s "$2"
|
||||
elif [[ "$1" == "-cd" ]]; then
|
||||
playlists -cd "$2"
|
||||
else
|
||||
help
|
||||
fi
|
||||
else
|
||||
help
|
||||
fi
|
20
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_Playlist#03.sh
Executable file
20
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_Playlist#03.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# bash script to create playlist files in music subdirectories
|
||||
#
|
||||
# Steve Carlson (stevengcarlson@gmail.com)
|
||||
|
||||
find . -type d |
|
||||
while read subdir
|
||||
do
|
||||
rm -f "$subdir"/*.m3u
|
||||
for filename in "$subdir"/*
|
||||
do
|
||||
if [ ${filename: -4} == ".mp3" ] || [ ${filename: -5} == ".flac" ] || [ ${filename: -5} == ".loss" ] || [ ${filename: -5} == ".aiff" ] || [ ${filename: -4} == ".aif" ]
|
||||
then
|
||||
echo "${filename##*/}" >> ./"$subdir"/"${subdir##*/}.m3u"
|
||||
fi
|
||||
done
|
||||
|
||||
done
|
||||
|
12
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_multi_directory.sh
Executable file
12
nixos_24.11_cinnamon/config/home/nemo_scripts/M3u/M3u_multi_directory.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
touch ${PWD##*/}.m3u
|
||||
export IFS=$'\n'
|
||||
for i in $(find $1 -name "*.mp3" -type f)
|
||||
do
|
||||
echo "$i" |sed 's/..\(.*\)/\1/' >> ${PWD##*/}.m3u
|
||||
done
|
||||
|
||||
shuf ${PWD##*/}.m3u > ${PWD##*/}2.m3u
|
||||
shuf ${PWD##*/}2.m3u > ${PWD##*/}.m3u
|
||||
rm ${PWD##*/}2.m3u
|
||||
exit 0
|
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
ls -d * | grep .mp3 > "${PWD##*/}.m3u"
|
||||
exit 0
|
Reference in New Issue
Block a user