-
-
Save scarlson/944860 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# | |
# bash script to create playlist files in music subdirectories | |
# | |
# Steve Carlson ([email protected]) | |
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 |
Thanks.
Hello everyone, based on this script and this other I created a function that wraps the main code and expect as arguments a flag [-r/-s] and a directory allowing it to have 2 modes: (-r) create one playlist per subdirectory and (-s) create a single playlist that includes all subdirectories' songs. With this script I maintain my playlists easily.
You can check it here: https://gitlab.com/-/snippets/2513870
Hello everyone, based on this script and this other I created a function that wraps the main code and expect as arguments a flag [-r/-s] and a directory allowing it to have 2 modes: (-r) create one playlist per subdirectory and (-s) create a single playlist that includes all subdirectories' songs. With this script I maintain my playlists easily. You can check it here: https://gitlab.com/-/snippets/2513870
i try to use your scripts, but i get an error message because the script goes to Homes/username/ Music. I want to change it to search in my music library which is not in the Home/username/Music directory. How can i change the script to search in whatever folder i want?
Hello everyone, based on this script and this other I created a function that wraps the main code and expect as arguments a flag [-r/-s] and a directory allowing it to have 2 modes: (-r) create one playlist per subdirectory and (-s) create a single playlist that includes all subdirectories' songs. With this script I maintain my playlists easily. You can check it here: https://gitlab.com/-/snippets/2513870
i try to use your scripts, but i get an error message because the script goes to Homes/username/ Music. I want to change it to search in my music library which is not in the Home/username/Music directory. How can i change the script to search in whatever folder i want?
give this a try https://github.com/mattiasghodsian/PhinellyPort
Hello everyone, based on this script and this other I created a function that wraps the main code and expect as arguments a flag [-r/-s] and a directory allowing it to have 2 modes: (-r) create one playlist per subdirectory and (-s) create a single playlist that includes all subdirectories' songs. With this script I maintain my playlists easily. You can check it here: https://gitlab.com/-/snippets/2513870
i try to use your scripts, but i get an error message because the script goes to Homes/username/ Music. I want to change it to search in my music library which is not in the Home/username/Music directory. How can i change the script to search in whatever folder i want?
give this a try https://github.com/mattiasghodsian/PhinellyPort
Thanks, Mattias
In the coming weeks, I will update my music library, and then I will try your script.
i will come back to you when I try it.
Ok - I re-read your code and hacked it like this
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
Then final version of my hacked script is below