Who likes random music on their player? [SOLVED]

Suggestions and feedback for Linux Mint and the forums
Forum rules
Do not post support questions here. Before you post read: Where to post ideas & feature requests
Post Reply
momist
Level 4
Level 4
Posts: 248
Joined: Mon May 21, 2012 3:30 pm
Location: Lancashire, Northwest England

Who likes random music on their player? [SOLVED]

Post by momist »

Is it just me? I love to have a large selection of random music on my MP3 player, and also on my phone. I usually make up a playlist of 4GB or so (that'll last me weeks) selected at random from my large music collection of about 50GB. The problem is that every couple of years the method of automatically getting a selection like that fails and I have to work it all out again.

I had a nice script once a few years ago, adapted from someone else's work, that I simply ran in whatever the current file manager was at the time (not the current one). Of course, when the file manager changed the script failed. I then had some random selector program written by another, but that went the same way. I've recently been using MrRandom, but that went very flaky during Mint 17 and with the update to Mint 18 it would only load about half a dozen songs and then keep stopping, so I was hammering the mouse to try to reach the target size. MrRandom seems to be no longer supported.

I'm now on Mint 19 and my music is on a separate 2TB USB drive that I have to plug in to my laptop (only at my desk!), so I could do to load a 4GB folder on the laptop to keep it portable again. I can't seem to find a suitable program any more that will work, and with my advancing age I'm not as good at writing scripts as I used to be. Just can't keep the attention up long enough, and keep forgetting things.

So, SUGGESTION: Why not add a neat little extra to the current file manager which would do this? It could be used for other things than music. For instance I could build a file of photographs which could be used on the desktop (I have again many many GB of those). Random podcasts anyone? How about random something else?
Last edited by momist on Fri Nov 23, 2018 12:08 pm, edited 1 time in total.
momist : a follower of the Greek god Momer.
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Who likes random music on their player?

Post by smurphos »

The default music player for Mint 19 - Rhythmbox has a shuffle option. If you activate it, highlight all albums and press play - you have random music. You can also do podcasts.

Image
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
momist
Level 4
Level 4
Posts: 248
Joined: Mon May 21, 2012 3:30 pm
Location: Lancashire, Northwest England

Re: Who likes random music on their player?

Post by momist »

Thanks smurphos, but as far as I know, it doesn't allow you to take some (say 1GB, or maybe 400 tracks) of that random selection, and transfer them to my phone, or to my MP3 player, or to my laptop. The 50GB I have is on a separate USB HDD that is used only when needed. I generally use VLC player the way you suggest.
momist : a follower of the Greek god Momer.
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Who likes random music on their player?

Post by smurphos »

Sorry I misunderstood (read - didn't read properly :) ) your post.

It shouldn't be hard to make a script to do this. What version of Mint and which Desktop Environment are you using? The three DE's all have different file managers.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
gm10

Re: Who likes random music on their player?

Post by gm10 »

Pretty simple indeed:

Code: Select all

ls|sort -R|head -n400|while read F;do cp -v "$F" /media/MP3PLAYER;done
This will copy 400 random files from the current folder to /media/MP3PLAYER. Adjust count and path(s) as needed.
User avatar
Pepi
Level 6
Level 6
Posts: 1308
Joined: Wed Nov 18, 2009 7:47 pm

Re: Who likes random music on their player?

Post by Pepi »

I always 'Shuffle' on all my players. It can be a real mood changer on 'those days'
momist
Level 4
Level 4
Posts: 248
Joined: Mon May 21, 2012 3:30 pm
Location: Lancashire, Northwest England

Re: Who likes random music on their player?

Post by momist »

@smurphos No worries. I'm using Mint 19.0 Cinnamon. Laptop with 30GB / and 38GB /home on SSD.
@gm10 Thanks. When I'm feeling more clear headed, I'll think my way through that, if I still can. :oops:
@Pepi. Yes! I sometimes go for a whole album, but very rarely. I can rock through a Pink Floyd, or sometimes some folk and only folk, or classical. But usually I prefer random.

Everyone: I have two music players, a magic cube and a very old Sansa Clip. Neither of those have 'shuffle' on them, and the cube doesn't open folders, everything has to be on the root. A random set from my collection onto my phone would be good too. I also want to put a random music set off the USB drive into the ~/music folder on the laptop, so I can use it anywhere. I only have 38GB for /home. I'd also like to put a random few hundred photos out of my large (100GB or so) collection onto the laptop to use as desktop background. The idea is to change these random selections, maybe once a month or so.
The simple answer to all these is to have a simple script that moves, say 400 files selected at random from a folder on the USB drive, into an empty folder on the laptop. From there it's simple to put them wherever I need them.

Of course, the laptop answer is to install a 2TB HDD in there, which may happen next year when I've saved up a bit.

Thank you all for your help!
momist : a follower of the Greek god Momer.
User avatar
all41
Level 19
Level 19
Posts: 9498
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Who likes random music on their player?

Post by all41 »

Who likes random music on their player?
I do.
Like you I have tons of music in multiple genres.
I use the VLC player in random mode throughout the day,
recording that randomness to file, and then copy to usb flash to use
in the car
Everything in life was difficult before it became easy.
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Who likes random music on their player?

Post by smurphos »

momist wrote: Sat Oct 27, 2018 6:31 pm @smurphos No worries. I'm using Mint 19.0 Cinnamon. Laptop with 30GB / and 38GB /home on SSD.
Building on gm10's timely example here is a small script and accompanying Nemo custom action which adds a right click option in Nemo to 'Get Random Files'.

Nemo is Cinnamon's file manager.

To see the right click option you need to click on a target folder and right click, or whilst in a target folder right click on empty space in the pane. As written it will get 400 random files from the folder and any subfolders and copy them to $HOME/Random-Selection. Amend the script TARGET and NUMBER variables to change this.

This folder is deleted and recreated each time it is run so after running the script you will want to move it or it's contents to the desired final location. You will get a notification at job start and job end.

The script - save this as ~/bin/get_random_files.sh and make executable.

Code: Select all

#!/bin/dash
# Check for existing instance and exit with notification
for PID in $(pgrep -f "get_random_files.sh"); do
    if [ "$PID" != $$ ]; then
        notify-send --expire-time=100000 --icon=dialog-warning "Cannot run get random files whilst another instance is running!"
        exit 1
    fi  
done
#Define target directory and number of files
TARGET="$HOME/Random_Selection"
NUMBER=400
#If target already exists delete it
if [ -d "$TARGET" ]; then
    rm -r "$TARGET"
fi
#Create target directory
mkdir "$TARGET"
#Send a notification for job start
notify-send --expire-time=100000  "Get random files is working....."
find "$1/" -type f | shuf -n"$NUMBER" | while read -r FILE; do cp -v "$FILE" "$TARGET/${FILE##*/}"; done
notify-send --expire-time=200000  "Your random files are in $TARGET"
The nemo custom action - save this as ~/.local/share/nemo/actions/get_random_files.nemo_action

Code: Select all

[Nemo Action]
Name=Get Random Files
Comment=Will select random files from target folder and copy them to $HOME/Random_Selection
Exec=get_random_files.sh %F
Selection=any
Extensions=dir;
EscapeSpaces=true
Image
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
gm10

Re: Who likes random music on their player?

Post by gm10 »

smurphos wrote: Sun Oct 28, 2018 1:27 am Building on gm10's timely example here is a small script and accompanying Nemo custom action which adds a right click option in Nemo to 'Get Random Files'.
Since I'm already involved, may I suggest this change to your script for interactive output directory selection?

Code: Select all

TARGET=$(zenity --file-selection --directory --title "Select target directory...")
if [ -z "$TARGET" ]; then exit; fi
Minus your target removal code, of course.
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Who likes random music on their player?

Post by smurphos »

gm10 wrote: Sun Oct 28, 2018 5:41 am Since I'm already involved, may I suggest this change to your script for interactive output directory selection?
Of course you may gm10. I've also added a zenity entry to choose the number of files. i don't think there is any need in this version to prevent multiple instances.

Version 2 - requires zenity to be installed - apt install zenity. On right click on a selected folder will ask the user to select a target directory and a number of random files to copy.

Version 2 script - save this as ~/bin/get_random_files.sh and make executable.

Code: Select all

#!/bin/dash
#Define target directory and number of files
TARGET=$(zenity --file-selection --directory --title "Select a target directory.")
if [ -z "$TARGET" ]; then exit 1; 
fi
NUMBER=$(zenity --entry --title="How many random files?" --text="Please enter an integer.")
if ! [ ! -z "${NUMBER##*[!0-9]*}" ]; then
   notify-send --expire-time=100000  "That's not an integer. Aborting operation. Please try again."; exit 1
fi
#Send a notification for job start
notify-send --expire-time=100000  "Get random files is working."
find "$1/" -type f | shuf -n"$NUMBER" | while read -r FILE; do cp -v "$FILE" "$TARGET/${FILE##*/}"; done
notify-send --expire-time=200000  "Your random files are in $TARGET"
Version 2 nemo action - save this as ~/.local/share/nemo/actions/get_random_files.nemo_action

Code: Select all

[Nemo Action]
Name=Get Random Files
Comment=Will select random files from target folder and copy them to a folder of your choice.
Exec=get_random_files.sh %F
Selection=any
Extensions=dir;
EscapeSpaces=true
Dependencies=zenity;
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
momist
Level 4
Level 4
Posts: 248
Joined: Mon May 21, 2012 3:30 pm
Location: Lancashire, Northwest England

Re: Who likes random music on their player?

Post by momist »

For anyone following this discussion:
I've found a 'work around' using the music player 'Clementine'. This will happily assemble a random playlist from my music selection into any target destination I choose, ready to transfer to my other device, or even direct to that device. The only drawback is that it then assembles them there in folders dedicated to a single artist, so they the device then plays all tracks from one artist followed by all tracks from the next etc.. Actually, I can tolerate that restriction for a while.
I am still looking for a definitive answer though, as this solution is only applicable to my music, and not to any other kind of file.
momist : a follower of the Greek god Momer.
gm10

Re: Who likes random music on their player?

Post by gm10 »

momist wrote: Tue Nov 06, 2018 6:38 am For anyone following this discussion:
I've found a 'work around' using the music player 'Clementine'. This will happily assemble a random playlist from my music selection into any target destination I choose, ready to transfer to my other device, or even direct to that device. The only drawback is that it then assembles them there in folders dedicated to a single artist, so they the device then plays all tracks from one artist followed by all tracks from the next etc.. Actually, I can tolerate that restriction for a while.
I am still looking for a definitive answer though, as this solution is only applicable to my music, and not to any other kind of file.
Most/all music players can do that. I use gmusicbrowser and it allows you to copy files from the randomly generated playlist anywhere as well - without creating folders.

But we already provided you with a general purpose solution above, with smurphos posting you a complete script to add to your file manager. What else are you still looking for... :?:
momist
Level 4
Level 4
Posts: 248
Joined: Mon May 21, 2012 3:30 pm
Location: Lancashire, Northwest England

Re: Who likes random music on their player? [SOLVED]

Post by momist »

Please accept my apologies to all on this thread.
My thanks and particular apologies are extended to smurphos and gm10 for their gallant efforts on my behalf. The script provided works excellently well, and gives me all that I need for the selection of both music and photographs from my external hard disk to generate a large, but not too large, randomly organised file on my SSD for my listening pleasure and also for desktop backgrounds. It provides a suitable varied random file for transfer to my music player and my phone.
All I have to do now is remember how to use it! I'll write myself a note in the laptop to remind me of he process. The reasons for the delay in implementation lie in both my social life and family responsibilities, and also in the increasing difficulty I am having in concentrating for long enough to follow through on any complex sequence of actions. I am finding more and more that old age is restricting my abilities, but today seems to be a good day for me.
momist : a follower of the Greek god Momer.
Post Reply

Return to “Suggestions & Feedback”