Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Script for automatic decoding of mpc (Read 4059 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Script for automatic decoding of mpc

I have a lot of mpc:s I want to decode to aiff/wav - where can I find script to do this automatically? I need nothing fancy, I just want

1. Title.mpc

to become

1. Title.aiff

but the mppdec just pipes the decoded mpc to stdout when I

mppdec *mpc /test/

Thanks in advance

Script for automatic decoding of mpc

Reply #1
Another problem easily solved by using SOX:

mppdec file.mpc - | sox - file.aiff
"To understand me, you'll have to swallow a world." Or maybe your words.

 

Script for automatic decoding of mpc

Reply #2
i use a bash script on linux for decoding:

Code: [Select]
#!/bin/sh
for file in *mpc
do
nice --adjustment=15 mppdec --wav "$file" .
done


--wav becomes --aiff quite easily 

...and nice isn't necessary, i just use it so it doesn't interfere with what i'm doing atm

if it is $(file).mpc.wav just rename:
rename 's/mpc.wav/wav/' *


later

Script for automatic decoding of mpc

Reply #3
Thanks for the bash script X.  I just installed the musepack-encoder package the other day.  (Why are you using the alpha as opposed to the beta?  I assume there's probably not that much difference between the two.)  I was trying to encode using the following:
Code: [Select]
mppenc --xlevel *.wav
but that didn't seem to work.  Adjusting your bash script worked out well for my encoding needs:
Code: [Select]
#!/bin/sh
for file in *wav
do
mppenc --xlevel "$file"
done


Do you know how to make a recursive bash script?  I am interested in ripping a bunch of CDs to the hard drive (one per subfolder) and I'd like to encode to MPC then replaygain all of them.  I am just learning about bash scripting so bear with me.  I hoped that X (or someone else) might have some cool scripts to share.

Script for automatic decoding of mpc

Reply #4
I pity windows users on a daily basis for their lack of a easy-to-use, powerful, general purpose scripting language.  Linux an Mac (owing to OS X's BSD heritage) have a a plethora from which to choose.  It's gotten to the point where I cannot operate a computer without being able to script things...  It is very difficult to suffer away on a Windows box that lacks cygwin.

There are at least two ways to make recursive bash scripts.  The most obvious way is to just call itself (any bash script behaves just like any other command).  For example, this would encode all wav files recursively in a directory tree (assume the script is named "mppall"):

Code: [Select]
#!/bin/bash
for file in *.wav; do
  mppenc --standard --xlevel "$file"
done
for file in *; do
  if [ -d "$file" ]; then
    cd "$file"
    mppall
    cd ..
  fi
done


You can also define functions.  Functions act exactly like mini shell scripts that operate within other shell scripts and are called the same way as anything else.  If you define a function in your .bashrc or .bash_profile (depending on your system, either may work, or just one...) it will be available in your shell environment and can be used like any other command.  They can also call themselves recursively.  This is the same script as the one above, except it uses a function and operates on it's command line parameters instead of the current directory.

Code: [Select]
#!/bin/bash
function mppdir() {
  for file in "$1"/*.wav; do
     mppenc --standard --xlevel "$file"
  done
  for file in "$1"/*; do
     if [ -d "$file" ]; then
       mppdir "$file"
     fi
  done
}

for param in "$@"; do
  mppdir "$param"
done


It first defines the function, then calls it for every command line parameter.  Isn't that just sexy?  You could probably do the same thing with "find" but I did it this way to illustrate the scripting technique.
I am *expanding!*  It is so much *squishy* to *smell* you!  *Campers* are the best!  I have *anticipation* and then what?  Better parties in *the middle* for sure.
http://www.phong.org/