From owner-freebsd-questions@FreeBSD.ORG Sat May 7 17:56:22 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D601A1065672 for ; Sat, 7 May 2011 17:56:22 +0000 (UTC) (envelope-from olivares14031@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6136E8FC14 for ; Sat, 7 May 2011 17:56:21 +0000 (UTC) Received: by bwz12 with SMTP id 12so4674066bwz.13 for ; Sat, 07 May 2011 10:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=0oEAneLhSr/zYNYf0gmE1AtfRD2IFZ7gZBf1QekcVlg=; b=J2FV6G9OhQccY5P6mUSraj/4yXbbYwJYIh9hFZCO8alrTAEpeDhE0BNacZY7SK7PE5 ocPWsdSF76hEcCGOEp5g/Auf6L1+82eQP4hnvk5Q0KmZETVVLvFzdjVXX/DSJlGCwamI I2gH0t5L5Qn/Poah+IsHezLnqR9MH0iEmRi6s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ishRP3qYWsS/IOF1vaS+98gVA2gslGeJoM8ZrTamRIGpdA86+GBeb4xyQdzy0Y6kQS vthDqzZxz2Ei+c0RyHfWCza17Fv/uqpKQLeSjh8+CJWwsVwuzgadPynzZI7+uU5Beo4R 2BjdwGB7NsT58laFlYiMcN87fIyKUrdpkd/Jo= MIME-Version: 1.0 Received: by 10.204.41.206 with SMTP id p14mr2951682bke.53.1304790980990; Sat, 07 May 2011 10:56:20 -0700 (PDT) Received: by 10.204.3.217 with HTTP; Sat, 7 May 2011 10:56:20 -0700 (PDT) Date: Sat, 7 May 2011 12:56:20 -0500 Message-ID: From: Antonio Olivares To: FreeBSD Questions Content-Type: text/plain; charset=ISO-8859-1 Subject: fix an audio conversion script to work through multiple directories and convert mp3s to ogg vorbis X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 May 2011 17:56:23 -0000 Dear kind FreeBSD users, I have a dilemma, I have a collection of songs in mp3 form from old cd's that I ripped. Sadly, the mp3s can play but with a screeching sound :(. I have confirmed that by converting the mp3's to ogg vorbis format, the screeching sound is lost. So I have decided to convert my songs to ogg vorbis. I have found a script that converts from any sound format to mp3, but I modified it to convert to ogg at 128 k which is default. The script that I modified is found at : http://en.linuxreviews.org/HOWTO_Convert_audio_files However, when I run it, I have to switch to the folder where the mp3's are at and run $ ./convert2ogg mp3 and when it is done $ ./renamer to rename the songs from *.mp3.ogg to *.ogg and then delete the mp3's manually. ========================================================== [olivares@acer-aspire-1 Download]$ cat renamer #!/bin/sh for i in *.mp3.ogg do mv "$i" "$(echo $i|sed 's/mp3.ogg/ogg/g')" done [olivares@acer-aspire-1 Download]$ cat convert2ogg #!/bin/sh # # Usage: convertoogg fileextention # if [ $1 = "" ];then echo 'Please give a audio file extention as argument.' exit 1 fi for i in *.$1 do if [ -f "$i" ]; then rm -f "$i.wav" mkfifo "$i.wav" mplayer \ -quiet \ -vo null \ -vc dummy \ -af volume=0,resample=44100:0:1 \ -ao pcm:waveheader:file="$i.wav" "$i" & dest=`echo "$i"|sed -e "s/$1$/ogg/"` oggenc -b 128 "$i.wav" "$dest" rm -f "$i.wav" fi done ========================================================== My question is the following: How can I run the script to recursively find all mp3's and convert them to ogg vorbis(with ogg extension already in place/or rename them in one step[instead of running two scripts] and deleting the mp3's) all in one time? Say I have a folder with songs: Los Invasores de Nuevo Leon -> Disc 1 -> Disc 2 -> Disc 3 . . -> Disc 20 And instead of going in manually and running the above scripts through each folder, run a modified script that will recursively find all mp3's in the directories and convert them to ogg, rename them and delete the mp3's? I know it can be done, but I am not expert and am afraid to screw up [see thread of updating freebsd with portmaster -af in case you have doubts]. I tend to shoot myself in the foot :( Something like $ find -iname "*.mp3" -exec ./convert2ogg ~/Los\ Invsores\ de\ Nuevo\ Leon/mp3 or similar that can do the job with a modified convert2ogg file that can rename the output correctly in the first step. Any suggestions/advice/comments/observations are welcome. I will attempt this on Monday on my machine at work since it is the one that has the screeching sound :( I will also try to get back a machine[the one with # portupgrade -af , # portmaster ?,etc] Regards, Antonio