Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-29-2009, 04:52 AM   #1
LQ Newbie
Registered: Nov 2009
Location: London
Distribution: Ubuntu
Posts: 11

Rep: Reputation: 4
Post Bash Script to convert FLAC album to Ogg Vorbis (preserving tags)


I wrote this simple bash script that you might find useful if you have all your music stored in FLAC but wish to convert some of it to Ogg Vorbis for use on your mobile music player.

I call the script

Here is the contents:


if [ $# -lt 1 ]; then
echo " "
echo "Please supply artist/albumname as argument, e.g. abba/gold"

if [ -d "$SRC_DIR" ]; then
echo " "
echo "Will Ogg encode the album $1 "
echo "from "
echo "$SRC_DIR"
echo "to "
echo $DEST_DIR
echo " "
if [ -d "$DEST_DIR" ]; then
echo "Destination already exists, will do nothing."
echo "Ogg encoding album $1 please wait..."
mkdir -p $DEST_DIR
for i in *.flac; do oggenc -q6 -o $DEST_DIR/${i%%flac}ogg $i; done
echo "Source directory $SRC_DIR does not exist, doing nothing."

echo "Finished."

HTH someone.
Old 12-30-2009, 08:57 AM   #2
Registered: Jun 2007
Posts: 152

Rep: Reputation: 37
saving for study - never know when you'll find a good nugget of info.
Old 10-16-2012, 12:33 PM   #3
LQ Newbie
Registered: Feb 2009
Posts: 13

Rep: Reputation: 1
This is neat.

Note that spaces in the filenames will cause oggenc to complain about multiple files. Wrapping both the destination argument and the file argument in quotes will fix that.

for i in *.flac; do oggenc -q6 -o "$DEST_DIR/${i%%flac}ogg" "$i"; done


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert MP3, OGG, WAV, CDA or FLAC to WMA JerryP Linux - Software 12 03-02-2014 04:23 PM
quick bash script to convert flac to mp3 zuralin Programming 8 08-19-2011 03:50 AM
Samba: On-the-fly Ogg Vorbis -> MP3 convert Xyem Linux - Server 2 04-11-2008 02:11 AM
Easy way to convert OGG Vorbis to mp3 on Fedora Antarctica Linux - Software 13 10-23-2007 07:45 PM
Need to convert MP3s to OGG Vorbis files crash_override_me Linux - Software 3 09-24-2005 12:13 PM > Forums > Linux Forums > Linux - General

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

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