LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-21-2006, 10:08 AM   #1
Phyrexicaid
Member
 
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176

Rep: Reputation: 30
Crappy MP3 player doesn't have a shuffle mode


Crappy MP3 player doesn't have a shuffle mode
So...

Should I try attempt to write a script that renames the files randomly so that I get a semi-random mode? (if so, I have no clue where to start)

OR

would a little java program be better/easier? Plus side here is that I could run it on windows and linux
 
Old 04-21-2006, 12:59 PM   #2
burntfuse
Member
 
Registered: Sep 2005
Location: Laurel, MD, USA
Distribution: Slackware 10.1, FC5
Posts: 164

Rep: Reputation: 30
Java might be easier...
 
Old 04-21-2006, 01:40 PM   #3
sw67
Member
 
Registered: Oct 2004
Location: Here
Distribution: Slackware 12, openSuSE 11.0, XP
Posts: 76

Rep: Reputation: 15
I'd say a bash script is simple enough.
This should do what you want:

Code:
#!/bin/bash
TT=$(ls | wc -l)
for i in *
do
	let "rn=$RANDOM % $TT"
	mv "$i" "$rn$i"
done
Put all your mp3s in a folder, save that script to something like random.sh (in the same directory as the mp3s), and run it.
Don't forget to do a chmod +x on the .sh file

What it'll do is loop through every file in the folder, and stick a random number in front of it, thereby effectively shuffling your playlist.

It does also rename itself, but that's something I can't be bothered to change right now

I wouldn't recommend putting it in your home diectory or anything like that, since it will rename **everything** in the current folder.

Hope it's helpful...
Sam
 
Old 04-22-2006, 01:13 AM   #4
Phyrexicaid
Member
 
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176

Original Poster
Rep: Reputation: 30
That is really helpful!

Thanks so much for posting that
 
Old 05-14-2006, 11:24 AM   #5
Phyrexicaid
Member
 
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176

Original Poster
Rep: Reputation: 30
Hey,

I've done some modification to the original script. The random number in front works pretty well, but the player seems to have an interesting way of ordering the songs, so in order to give it less options I want to only have a number in front of .mp3, I then have a restore script that can regenerate all the file names. Only problem is that now I have the possibility of overwriting a file. How can I check to see that a file won't be overwritten? (My script writing abilities aren't the best) And... horror of horrors, anyone know how to convert this to a .bat file so that I can run this in windows and linux
Code:
TT=$(ls *.mp3 | wc -l)
for i in *.mp3
do
	let "rn=$RANDOM % $TT * 2"
        let "rn2=$RANDOM % $TT"
	echo "mv \"$rn - $rn2.mp3\" \"$i\"" >> restore.sh
	mv "$i" "$rn - $rn2.mp3"
done
echo "rm restore.sh" >> restore.sh
 
Old 05-14-2006, 12:35 PM   #6
Phyrexicaid
Member
 
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176

Original Poster
Rep: Reputation: 30
Could someone shed some light on this;
The way this mp3 player actually plays songs is beyond me. I have the following songs in order (this is from the restore script) but when I play the songs on the mp3 player, it starts with Breakerfall, and then plays all the songs in order after that (Evacuation, Fly Paper jet etc). Now they obviously don't follow sequencially looking at their names. And when I restore their original names it starts playing "A Perfect Circle". WTF is going on?!?

It plays according to a directory listing when I don't change anything. When I run the randomiser, it starts on some arb song but then starts playing in order again! Huh? How?

Code:
mv "AA - 29 - 87 - 18.mp3" "A Perfect Circle - Mer De Noms - 02 - Magdalena.mp3.mp3"
mv "AA - 69 - 51 - 9.mp3" "A Perfect Circle - Mer De Noms - 03 - Rose.mp3.mp3"
mv "AA - 2 - 14 - 68.mp3" "A Perfect Circle - Mer De Noms - 07 - Sleeping Beauty.mp3.mp3"
mv "AA - 21 - 70 - 88.mp3" "A Perfect Circle - Mer De Noms - 08 - Thomas.mp3.mp3"
mv "AA - 58 - 30 - 64.mp3" "A Perfect Circle - Mer De Noms - 10 - Thinking Of You.mp3.mp3"
mv "AA - 38 - 3 - 22.mp3" "A Perfect Circle - Mer De Noms - 11 - Brena.mp3.mp3"
mv "AA - 9 - 13 - 72.mp3" "Alice In Chains - 03 Rain When I Die.mp3.mp3"
mv "AA - 14 - 2 - 45.mp3" "Alice In Chains - 08 Dirt.mp3.mp3"
mv "AA - 16 - 42 - 55.mp3" "Alice In Chains - 13 Would.mp3.mp3"
mv "AA - 59 - 47 - 31.mp3" "Alice in Chains - 01 Grind.mp3.mp3"
mv "AA - 83 - 60 - 29.mp3" "Alice in Chains - 12 Angry Chair.mp3.mp3"
mv "AA - 85 - 41 - 80.mp3" "Alice in Chains - 12 Over Now.mp3.mp3"
mv "AA - 6 - 27 - 78.mp3" "Breakerfall.mp3.mp3"
mv "AA - 58 - 48 - 43.mp3" "Evacuation.mp3.mp3"
mv "AA - 41 - 1 - 57.mp3" "Fly Paper Jet Live - Festival Song.mp3.mp3"
mv "AA - 16 - 40 - 60.mp3" "Fly Paper Jet Live - The Light Fantastic.mp3.mp3"
mv "AA - 22 - 33 - 57.mp3" "God's dice.mp3.mp3"
mv "AA - 78 - 31 - 60.mp3" "Grievance.mp3.mp3"
mv "AA - 34 - 47 - 13.mp3" "Insignificance.mp3.mp3"
mv "AA - 73 - 1 - 45.mp3" "Light years.mp3.mp3"
mv "AA - 15 - 69 - 16.mp3" "Limp Bizkit - 02 - eat you alive.mp3.mp3"
mv "AA - 44 - 65 - 41.mp3" "Limp Bizkit - 15 - behind blue eyes.mp3.mp3"
mv "AA - 19 - 55 - 53.mp3" "Limp Bizkit - 16 - drown.mp3.mp3"
 
Old 05-16-2006, 11:16 AM   #7
Phyrexicaid
Member
 
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176

Original Poster
Rep: Reputation: 30
Hmmmmmm.

Okay, so I used id3 -d to delete the id3 tags from the files. Turns out (obviously) that the mp3 player was reading id3 tags after reading the first random song number. Now how to remove the id3 tags but be able to restore them like I can with the restore script?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a .mp3-player an .ogg-player? firmware available ungua Linux - Software 2 01-18-2006 10:54 AM
S1 Mp3 player (Help Create a New Distro for an MP3 player!)) Ian_Hawdon Linux - General 3 12-05-2005 01:14 PM
mount mp3 player to /mnt/mp3? Muzzy Linux - General 4 05-09-2004 05:31 AM
iRiver iHP-120 20GB MP3 Player, a player for the rest of us ? dukeinlondon General 1 04-04-2004 04:44 AM
MP3 CD player can't read MP3 CD's burned in linux food188 Linux - Software 2 01-11-2004 04:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration