-
🕶️ @haseciluAuthor Ownerto use the playlist for any directory
Hi, did you refer the script?
- For the
playlists_recursive.shfile, just change$HOME/Musicon line 12 to your directory. - For the
playlists.shfile, inside thedefaultfunction you can change the directories that are passed toplaylistsfunction. Thedefaultfunction is just a reference and it's only executed if no arguments are passed to the script from the shell, ideally you should use the script with the-s/-rflag and a directory as argument (check the asciinema cast), the argument is not tied to$HOME/Musicdirectory so you can use any valid directory!. I use thedefaultfunction to "save" the commands I have used to create my playlists just in case they're deleted and I want to create them again (1-rcall and 22-scalls).
- For the
-
I tried the playlist_recursive.sh. I change the $Home/Music into /volume1/music/flac, but it didn't work
i got an error message like this:
I maybe forgot to mention that my files reside on NAS storage.
-
i tried the second script. I put some music files in a directory called /volume1/Music/test. Test is where i put some albums with no playlist Then i go to the Test directory via the commandline and execute the following:
bash playlists_single.sh -r /volume1/Music/test Before i changed my user into root, so i execute the script as root
I got an error message like this:
-
🕶️ @haseciluAuthor Ownerthe results
On line 12 it complains of
cdbut is not even used. It also complains of\r(line break), what OS is your server using? line breaks are different on Windows from Linux, -
🕶️ @haseciluAuthor Ownerbash playlists_single.sh -r /volume1/Music/test Before i changed my user into root, so i execute the script as root
lolcatis a program that puts rainbow colors when printing text and you have to install it to use it, it just a plus for visual aesthetics, not really needed, (1) remove the| lolcatpart, it appears 3 times. Once removed the text will be printed just with boring white text; or (2) turn off verbosity.Edited by Ulices -
The OS is Linux. I run it on the command line interface of the Synology NAS
I don't run lolcat, but it shouldn't be a problem
How can turn off verbosity. I'm not a Linux expert. I don't know all the commands. And if I do that will the scripts work?
Here under is an example of how I changed the Home/Music directory
I run the script like this:
The results:
-
🕶️ @haseciluAuthor OwnerThe OS is Linux.
I have not had problems with my Debian server, no Synology stuff.
How can turn off verbosity.
On the
playlists.shscript on line 12, change the variable fromv=1tov=0but I recommend you to delete the| lolcatfrom the script because from the text output you will know if the script ran as expected.The results:
It looks like the bash shell is not interpreting correctly the character
\r, usually that's a problem between unix/linux and windows. Try running commandsed -i 's/\r$//' playlists.shto remove them and then run again the script. -
I found a solution to the problem. It seems like it was my Synology NAS that was the problem.
I mount the music folder on another linux server and from there i run the script. i only change the directory and it works. I did it for the recursive scripts but i think it will also work for the single script
Thanks for your help in trying to find a solution.
-
🕶️ @haseciluAuthor OwnerGood to know that it finally worked.
-
I have a problem regarding the script. As I mentioned before the script worked just fine on another computer, but the script can't work in a situation where your albums consist of multiple CDs. It creates the m3u8 file but the file is not unique so I can't move all the playlist files to a centralized folder. It would help if the playlist filename was a composition of the album name and CD number like so "Hits of the 70s-CD1.m3u8". That would create a unique name.
-
🕶️ @haseciluAuthor OwnerThe name of the playlist is the name of the directory so, how are your directories organized?
If you have
album,album/CD 1,album/CD 2, using single mode will create a playlist called album but using recursive mode will create 2 playlists called "CD 1# and "CD 2" and then manually rename it to "album CD 1" and "album CD 2", but it this last case it's better to just have the 2 directories calledalbum CD 1andalbum CD 2. The generated playlists will be unique if the directories' names are unique. I have my library organized in a way that I only need the single and recursive mode, maybe renaming directories does the trick for you.Alternatively create another "mode" in the script to consider your case, check this link.
Edited by Ulices -
I don't have a problem that it creates CD1 and CD2, except that I can't collect all the playlists and put them in a central folder because there might be other tracks with also a CD1 and CD2 playlist. I check the link you just posted but I'm not sure if I understand what the discussion was about since I'm not a script expert. The only thing I am saying is that if the cd playlist name was a composition of the album name and then CD1 like this (like a Virgin-CD1) and (Like a Virgin-CD2) it would help me a lot, cause then I can put all the playlist in one central folder because each playlist name is unique
-
🕶️ @haseciluAuthor OwnerIs possible to rename the directories, like:
70s CD 1,70s CD 2,80s CD 1,80s CD 2, etc. That would create the playlists with different names and not justCD 1,CD 2, but I don't know if renaming the directories breaks something in your library organization scheme. -
🕶️ @haseciluAuthor Owner -
🕶️ @haseciluAuthor OwnerOk, I have updated the script, test it and check it works as expected.
-
🕶️ @haseciluAuthor OwnerNo, the other one. You have to use:
./playlists -cd /path/to/Music/Albumand only use-cdwhen the directory is a album that contains CDs, for the other cases use-sor-r. Also if you don´t have figlet and lolcat install them or remove the lines that have them.I'm planning to remove the
playlists_recursive.shfile because the functionality is exactly the same that./playlists -r /Music/Albumand it's essentially a copy from the scripts from GitHub. -
Ok, I understand but I'm not always aware that an album has CD1 CD2, and more. for a small collection, you can check it but not if you have 10.000+ albums. You are not going to check every album to see if there are CD sections. Normally I run the script for all albums in my music directory. Now I have to do it on a case-by-case base.
What are figlet and lolcat? Where can I find them?
-
🕶️ @haseciluAuthor OwnerIn the way the code is now you could first run
-ron the root music directory and then-cdon the subdirectories with CDsntimes, otherwise you need an intelligent script that detects if the current directory containsCD 1orCD 2.What are figlet and lolcat? Where can I find them?
Terminal programs "for ornament", search how to install them in your OS.
-
Ok thanks so far! I let you know tomorrow how it goes.
I think for now the best thing to do is to remove the line with figlet and lolcat. Since i never use them i don't think i need to install them at this point.
One last question. Did you mean that I can run the script with -cd on the root folder too in order for it to change the subdirectory playlist or do I have to run it for each subdirectory with a CD?
-
🕶️ @haseciluAuthor OwnerNo, just
-ron the root and-cdon the specific directories. In my personal case I use-ron root and 22 times-son some directories. -
I test your script and it works, except for the fact as you already stated for directories with a CD I have to do separate commands with the -cd option. For 5 albums I can do it but not for 10.000 albums. Taking that into account I decided to take another approach. I change the script for my music renaming so every subdirectory will consist of the Albumname and CD(n) if there is a CD but if there is no CD it will not show. That creates for every album and subfolder a unique name. In that case, I can use your script with only the -R option and it will create the appropriate unique m3u8 file I can still use the script with the -cd option in a situation where I want to add just a couple of albums
What I want to know is, if I run the script once, if by running it a second time if it deletes the previous m3u8 files and creates a new one?
-
🕶️ @haseciluAuthor OwnerYou have to add the script to the
PATHi.e., copy the script to a directory where are other executables files. Copy to$HOME/.local/bin, preferably with no extension:cp playlists.sh $HOME/.local/bin/playlists.Yes, it will delete previous files THAT ARE IN THE SAME SUBDIRECTORY. If you run
-ron root and creates 50 playlists and then-s/-cdon a subdirectory that already have 5 playlists, those 5 will get removed an will be replaced by the one(s) generated with the second command, the other 45 playlist will not be removed!. If you don´t want to delete them (the 5) comment line 22:find . -type f -name "*.m3u*" -delete # If "-delete" didn't work use: "-exec rm {} \;"but that could create duplicates. -
Ok, when it comes to your first point I did exactly what you stated. I copy the script to my $HOME directory, but there was no .local /bin so I created it. In the bin folder, I create a subfolder called playlists. In the playlist subfolder, I put the script called playlist-flac. It is the same script but I gave it another name. But it did not work. Not a big deal since I can run the script in another way.
When it comes to your second point, I prefer to delete all the m3u8 files if I have to run the script again in order to prevent duplicates. The reason for that is that sometimes you already have a playlist, but the tracks changed. For example, you have an album with 10 tracks but you are missing 2 tracks. The Album consists of 12 tracks. If you don't create a new playlist you will have a playlist with 10 tracks while your updated album has 12 tracks. That's why I prefer to delete everything every time I run the script.
-
Hello. This script is awesome, thanks so much for sharing it.
I'm wondering if it's possible to include the artist name in the produced .m3u playlist ?
I have a well organized directory structure as follows.
Artist / Album / Songs
I'd love to be able to use the recursive mode to create playlists in each album folder and for the playlist name to contain both the artist name and the album name. Currently using the recursive option, the album name is only included. The reason for this request is that I'm planning to import the playlists into my self-hosted music app and with just the album name in the playlist name, it's very hard to know which playlist is for which artist, but with the artist name included it would be very easy as all the playlists are sorted alphabetically.
Thanks !
-
🕶️ @haseciluAuthor OwnerHi @irishjob, because the way in which the directory is traversed is such that it doesn't enter into the last subdirectories which in your case means that the last directory it enters is the Artist one, so it's easy to refer to it using
PWD.echo "${filename##*/}" >>"$subdir/${PWD##*/} - ${subdir##*/}.m3u8" [ "$v" -eq 1 ] && echo -e "${PWD##*/} - ${subdir##*/}.m3u8\t\t${filename##*/}" | lolcatTest the new
-raflagEdited by Ulices -
Hi @hasecilu - Thanks for your update.
I've tried the updated script with the "-ra" flag and it works well when I point it to a specific artist directory, say for example "The Beatles" and it does include the artist & album name into the playlist name for each album within the artist directory, excellent.
The only problem I'm experiencing, is when I point it to the root directory where all my music resides, which is named "FLAC", so it processes every artist / album directory recursively, it's including "FLAC" as the artist name for all the playlists.
Directory structure would be "FLAC / Artist / Album / Songs".
Any way to get around this ?
Thanks so much for your time.
-
🕶️ @haseciluAuthor OwnerMmmm, I oversimplified the case, use the
-cdflag, I think that's what you're looking for. -
Tried the "-cd" flag and this works good, the only outstanding issue is that there only a space separator between the artist name and the album name when the playlist is generated.
Example : ABBA Arrival (1976).m3u8
Is it possible to have a "-" between the artist and album name, so instead it would look like this.
Example : ABBA - Arrival (1976).m3u8
Thanks !
-
🕶️ @haseciluAuthor OwnerReplace:
album_cd=$(basename "$album")/$(basename "$subdir") album_cd=${album_cd//\// } # Replace '/' for space ' 'To
album_cd="$(basename "$album") - $(basename "$subdir")"
Please register or sign in to comment

