Looking for guidance on generating an script to randomize the greetings file
by elnetotaca from LinuxQuestions.org on (#560EE)
Whats up guys, I am trying to figure out how to generate an script that will choose and randomize within 10 different .mp3 files to play as the main greetings file on my laptop.
so far this is how much I've gotten....(I know, not far, lol)
#!?bin/bash
original=greetings.mp3
rename=raNum
#It will randomize within 10 greeting files.
ranNum=$[1 + RANDOM % 10]
[ $(mv -i $original $ranNum) ]
I want to do this keeping the previous file, as you can see, right now I am just replacing greetings.mp3 to a number generated by the function, but obviously that is not exactly what I want to do.
any ideas???
I will appreciate VERY MUCH the help.
THANKS!
EDIT.
progress!!!!
#!?bin/bash
original=greetings.mp3
$2=
#It will randomize within 10 greeting files.
ranNum=$[1 + RANDOM % 10]
#swap names
function swap()
{
local TMPFILE=tmp.$$
mv "$original" $TMPFILE && mv "$2" "$1" && mv $TMPFILE "$2"
}
now I'm stuck, lol
Edit #2
#!?bin/bash
original=greetings.mp3
#It will randomize within 10 greeting files.
ranNum=$[1 + RANDOM % 10]
if raNum=1
{$2=1.mp3
if raNum=2
{$2=2.mp3
if raNum=3
$2=3.pm3
#swap names
function swap()
{
local TMPFILE=tmp.$$
mv "$original" $TMPFILE && mv "$2" "$1" && mv $TMPFILE "$2"
}
I feel like I'm moving forward, but there's gotta be an easier way....


so far this is how much I've gotten....(I know, not far, lol)
#!?bin/bash
original=greetings.mp3
rename=raNum
#It will randomize within 10 greeting files.
ranNum=$[1 + RANDOM % 10]
[ $(mv -i $original $ranNum) ]
I want to do this keeping the previous file, as you can see, right now I am just replacing greetings.mp3 to a number generated by the function, but obviously that is not exactly what I want to do.
any ideas???
I will appreciate VERY MUCH the help.
THANKS!
EDIT.
progress!!!!
#!?bin/bash
original=greetings.mp3
$2=
#It will randomize within 10 greeting files.
ranNum=$[1 + RANDOM % 10]
#swap names
function swap()
{
local TMPFILE=tmp.$$
mv "$original" $TMPFILE && mv "$2" "$1" && mv $TMPFILE "$2"
}
now I'm stuck, lol
Edit #2
#!?bin/bash
original=greetings.mp3
#It will randomize within 10 greeting files.
ranNum=$[1 + RANDOM % 10]
if raNum=1
{$2=1.mp3
if raNum=2
{$2=2.mp3
if raNum=3
$2=3.pm3
#swap names
function swap()
{
local TMPFILE=tmp.$$
mv "$original" $TMPFILE && mv "$2" "$1" && mv $TMPFILE "$2"
}
I feel like I'm moving forward, but there's gotta be an easier way....