Find the answer to your Linux question:
Results 1 to 9 of 9
I want to make a shell script that will take mp3's convert them to wav or whatever they need to be burn the cdrom and then delete the wav files ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314

    Burning a music cd from mp3s


    I want to make a shell script that will take mp3's convert them to wav or whatever they need to be

    burn the cdrom and then delete the wav files all in one command

    also this script will be reading from a file that will tell it where all the mp3s are at.

    does anybody know of such a script or can any one help me make one.

    im thinking i want to do it in PERL. does anybody have any suggestions

    Thanx for reading
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I have already made such a shell script, that not only does that, but also it uses FIFOs instead of temp files, so it uses no disk space at all. Now, this script was lost when my former hard drive crashed, but it was simple, so I'll write a new one for you here:
    Code:
    #!/bin/sh
    if [ $# -eq 0 ]; then
        exec 3<&1
    else
        exec 3<"$1"
    fi
    cmdline="cdrecord dev=0,0,0 speed=16 -v -audio"
    read numfiles <&3
    i=numfiles
    fifoname=/tmp/cdtrack1
    while let i--; do
        cmdline="$cmdline $filename"
        if &#91; "$filename" = /tmp/cdtrack1 &#93;; then
            fifoname=/tmp/cdtrack2
        else
            fifoname=/tmp/cdtrack1
        fi
    done
    i=numfiles
    cdrpid=
    mkfifo /tmp/cdtrack&#123;1,2&#125;
    fifoname=/tmp/cdtrack1
    first=true
    while let i--; do
        read filename <&3
        mpg123 -s $filename >"$fifoname" &
        mpgpid=$!
        if &#91; "$filename" = /tmp/cdtrack1 &#93;; then
            fifoname=/tmp/cdtrack2
        else
            fifoname=/tmp/cdtrack1
        fi
        if &#91; -z $cdrpid &#93;; then
            $cmdline &
            cdrpid=$!
        fi
        if &#91; -z $first &#93;; then
            wait $mpgpid
        else
            unset first
        fi
    done
    wait $cdrpid
    rm /tmp/cdtrack&#123;1,2&#125;
    exec 3<&-
    As you can see, it takes the file list from either a named file, or from stdin if no name given, and the first line of the file must be the number of tracks. It also requires mpg123 or mpg321. It always sees to it that two mpg123s are running, so that there won't be any gap when cdrecord wants to begin a new track.
    I haven't tried this new version of the script, so I don't know if it works, but then on the other hand, I see no reason why it shouldn't.

  3. #3
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    cant get it to work

    i typed this in to the music file

    2
    01\ -\ Enter\ Sandman.mp3
    02\ -\ Sad\ But\ True.mp3

    and it tells me that cdrecord needs tracks to record

    heres the command I used to start it

    ./cdwriter.sh music
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Yeah, you don't say? =)
    I had messed up a bit, mistaking $filename for $fifoname. But most of all, now that I tried it, I noticed that cdrecord opens all files before it does anything else, which means that I must use a FIFO for every track. Try this version instead:
    Code:
    #!/bin/sh
    if &#91; $# -eq 0 &#93;; then
        exec 3<&1
    else
        exec 3<"$1"
    fi
    cmdline="cdrecord -dummy dev=0,0,0 speed=16 -v -audio"
    tempdir="$&#40;mktemp -d /tmp/cdwriteXXXXXX&#41;"
    trap 'rm -rf "$tempdir"' EXIT
    read numfiles <&3
    i=0
    while let i++\<numfiles; do
        cmdline="$cmdline $&#123;tempdir&#125;/track$&#123;i&#125;"
        mkfifo "$&#123;tempdir&#125;/track$&#123;i&#125;"
    done
    i=0
    fifoname=/tmp/cdtrack1
    while let i++\<numfiles; do
        read filename <&3
        mpg123 -qs "$filename" >"$&#123;tempdir&#125;/track$&#123;i&#125;" 2>>mpg123.log &
    done
    $cmdline
    exec 3<&-
    Also, in this version, I remembered to quote the filename to mpg123, you don't need to quote it in the list file anymore.

  6. #5
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    adam@bignasty:~/cdwrite$ ./cdwriter.sh music
    -d option is not supported under Linux.
    mkfifo: cannot create fifo ``/track1'': File exists
    mkfifo: cannot create fifo ``/track2'': File exists
    ./cdwriter.sh: line 20: /track1: Permission denied
    ./cdwriter.sh: line 20: /track2: Permission denied

    why is it trying to write to my root directory

    it still doesnt work am i doing something wrong
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  7. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Strange, that worked for me, and it shouldn't be trying to write to your root directory. You might want to remove the -dummy option, though. I see I happened to leave it in place. Are you sure that you copied it exactly as it says there? I''ve put it up on my HTTP server instead. Try getting it from http://www.dolda2000.cjb.net/~fredrik/lf/cdwrite.
    Remember also, that you will need to either run this script as root, or make sure that your cdrecord binary is setuid root.

  8. #7
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    figured out my problem for some reason mkfifo isnt working properly

    here is what i changed

    #!/bin/sh
    if [ $# -eq 0 ]; then
    exec 3<&1
    else
    exec 3<"$1"
    fi
    cmdline="cdrecord dev=0,0,0 speed=16 -v -audio"
    #tempdir="$(mktemp -d /tmp/cdwriteXXXXXX)"
    tempdir="/tmp/music"
    trap 'rm -rf "$tempdir"' EXIT
    read numfiles <&3
    i=0
    while let i++\<numfiles; do
    cmdline="$cmdline ${tempdir}/track${i}"
    mkfifo "${tempdir}/track${i}"
    done
    i=0
    fifoname=/tmp/cdtrack1
    while let i++\<numfiles; do
    read filename <&3
    mpg123 -qs "$filename" >"${tempdir}/track${i}" 2>>mpg123.log &
    done
    $cmdline
    exec 3<&-

    problem is i have to make the music directory every time i want to use it

    would you know why the mkfifl isnt working right
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  9. #8
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    new problem cant conver my mp3 files

    my mp3 files play fine but for some reason when i convert them to a wav file or some other type of file the screw up and dont work
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  10. #9
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    mkfifo? Don't you mean mktemp? I have no idea why it doesn't work; probably you're running some strange version of it. Just add the following after you set tempdir and you should be fine.
    Code:
    mkdir "$tempdir"
    How do you mean that you can't convert them? How are you trying?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •