You are not logged in.

#1 2015-06-16 07:19:07

Aerial Boundaries
Member
Registered: 2015-05-15
Posts: 26

Cmus 2.6.0 - Excluding certain folders from library

Apologies if this is a dumb question, but for the life of me I can't figure this out.

For specific reasons I am unable to have music in separate folders, which means I end up with multiple versions of the same album, as well as music that I simply don't like (but need to keep) in the folder that I point Cmus to.

I am in need of a way to tell Cmus not to read specific music folders within the overall folder.

For instance, if my main folder is '/mnt/sda1/music', I would want to exclude '/mnt/sda1/music/example' while keeping the other subfolders.

I have tried doing so with filters, but haven't had any luck because != or =! aren't recognised. There don't appear to be any plugins or patches available that will let me do so. I have googled extensively for a solution, read the man pages and of course the arch and cmus wikis. Note that I am also not able to rename any of the folders in question, so any solution cannot rely on that.

Perhaps a bash script of some sort executed when starting cmus could work, but I wouldn't know where to begin or what mechanism it would use.

Any insight or suggestions would be much appreciated smile

Offline

#2 2015-06-22 21:44:29

karlch
Member
Registered: 2015-06-14
Posts: 105

Re: Cmus 2.6.0 - Excluding certain folders from library

Of course the manual way would always be possible, namely deleting the unwanted files once using "D" in cmus and then adding new files with ": add /mnt/sda1/music/new". This could becoming pretty annoying if the library is large.

A probably by far too complicated bash script I tested quickly is the following:

#!/bin/bash

shopt -s extglob
urxvt -e cmus &
# Needed so cmus has completely started when cmus-remote runs
sleep 0.2
# Clear all the songs from the library
cmus-remote -c -l
# Not very elegant, do improve it for your needs
toadd=`ls /mnt/sda1/music/!(example1|example2) | grep : | tr -d ':'`
while read -r line; do
    cmus-remote -C "add $line"
done <<< "$toadd"

You may need to change the "urxvt -e" part to fit your favourite terminal emulator and possibly the length of sleep depending on your system's speed.

Downsides: clearing and adding everything all the time seems a ridiculous way to solve the problem, starts a new terminal with cmus (although this makes it possible to run the script on a keybinding)

Hope this helps if only by delivering ideas. smile I am new to the forums so don't go too hard on me big_smile

EDIT:

If you modify the script slightly (leaving away the urxvt and the sleep part), you could bind the script to a key in cmus as an addition to the exisitng add command.

Last edited by karlch (2015-06-23 05:39:17)

Offline

#3 2015-06-23 04:09:40

grandtheftjiujitsu
Member
Registered: 2013-07-27
Posts: 91

Re: Cmus 2.6.0 - Excluding certain folders from library

Try an alias in your ~/.bashrc like this

alias cmus="cmus add -l /path/directories/to/include/{dir1,dir2,dir3}"

Offline

Board footer

Powered by FluxBB