
* Leslie Katz <lesliek(a)ozemail.com.au> [2006-05-24 11:20]:
Well, I made that sole change to the script and did exactly what I did before.
The output I got this time was as follows:
Beethoven1.wma => Beethoven1.wav Could not find "Beethoven1.wav". Beethoven2.wma => Beethoven1.wav Could not find "Beethoven2.wav".
and then the prompt.
Strange. I guess quitting and restarting XMMS constantly is inevitable. #!/bin/bash CFG=~/.xmms/config mv "$CFG" "$CFG".orig || { echo "Couldn't back up $CFG" 1>&2 ; exit 1 ; } sed 's/libOSS.so/libdisk_writer.so/g' "$CFG".orig > "$CFG" for src in *.wma ; do base="${src%.wmv}" temp="$base".wav echo "$src => $temp" xmms "$src" while xmmsctrl playing ; do sleep 1 ; done xmmsctrl quit lame "$temp" "$base".mp3 && rm "$temp" done mv "$CFG".orig "$CFG" Say, do you have MPlayer? That would make things much simpler, since you could decode files without monkeying with an X11 application that wasn’t intended for non-interactive use: #!/bin/bash for src in *.wma ; do base="${src%.wmv}" temp="$base".wav echo "$src => $temp" mplayer -really-quiet -novideo -ao pcm:filename="$temp" "$src" \ && lame "$temp" "$base".mp3 \ && rm "$temp" done Which makes me think, you can make either incarnation of the script more useful by changing the loop to the following: for src in "$@" ; do base="${src%.*}" You can then invoke it explicitly with a list of filenames, eg. if the script is called `to-mp3`, you’d say `to-mp3 *.wma`. By chaning `${src%.wma}` to `${src%.*}`, it will remove *any* extension from the file, regardless of what it is, so you can also say `to-mp3 *.ogg *.ra` to convert Ogg Vorbis and RealAudio files (well, XMMS can’t play RealAudio, but MPlayer can). Carter’s Compass: I know I’m on the right track when by deleting something I’m adding functionality. (Okay, in this case, it wasn’t really any deletion, but in most cases I’ve found that scripts and utilities become more useful the more code you delete outside the invariants.) Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>