LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 11-29-2009, 04:52 AM   #1
will177
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)


Hi,

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 OggEncodeAFLACAlbum.sh

Here is the contents:


#!/bin/bash

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

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

echo "Finished."


HTH someone.
 
Old 12-30-2009, 08:57 AM   #2
SethsdadtheLinuxer
Member
 
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
Arancaytar
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.

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


Reply


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


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

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