Date: Sun, 8 May 2011 22:37:59 -0400 (EDT) From: Chris Hill <chris@monochrome.org> To: Antonio Olivares <olivares14031@gmail.com> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: fix an audio conversion script to work through multiple directories and convert mp3s to ogg vorbis Message-ID: <alpine.BSF.2.00.1105082216190.41771@tripel.monochrome.org> In-Reply-To: <BANLkTikbYdiNnQRGYaK3m0DTehWK=32W4w@mail.gmail.com> References: <BANLkTi=NZv0AF3UAnGxVy1rt6Kb8kP3Y3g@mail.gmail.com> <alpine.BSF.2.00.1105071656030.39181@tripel.monochrome.org> <BANLkTikbYdiNnQRGYaK3m0DTehWK=32W4w@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 8 May 2011, Antonio Olivares wrote: > On Sat, May 7, 2011 at 4:03 PM, Chris Hill <chris@monochrome.org> wrote: >> On Sat, 7 May 2011, Antonio Olivares wrote: >> >>> 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? >> >> I had a similar (but not identical) problem [ snip ] >> My script is at http://pastebin.com/77NRE6SZ - maybe you can adapt it >> to your needs. > Thank you for your suggestion. But I have gotten into a problem I get > errors and too many directories :(, Directories with spaces get > recreated and no ogg files are created :( If your directory and/or file names have spaces, you will have to quote the filenames somehow: 'file name' vs. file_name. Maybe you could escape the spaces? None of my names have spaces, for exactly this reason. [ Script mostly snipped ] > ===================================================== > #!/bin/sh > # From Steve Parker, only slightly modified: [ snip ] > traverse() > { > # Traverse a directory > > ls "$1" | while read i > do > if [ -d "$1/$i" ]; then > THISDIR=$1/$i > # Calling this as a subshell means that when the called > # function changes directory, it will not affect our > # current working directory > > if [ -d $OGGROOT/$THISDIR ]; then > # directory exists, leave it be > echo "$OGGROOT/$THISDIR already exists, not created." > else > mkdir $OGGROOT/$THISDIR > echo "Copying $THISDIR to $OGGROOT/$THISDIR" > fi > > traverse "$1/$i" `expr $2 + 1` > else [ snip ] > fi > done > } > > traverse . 0 > ===================================================== > > I have modified to above script. I don't get how the directory > structure is copied? I don't see a cp -r from_directory/ to > _directory/ then mplayer -ao .... There is no cp -R. What this is doing is replicating the directory structure, then copying each file. I missed it too, the first several times I looked at it. Almost the entire script is the definition of the traverse() function, which is called in the last line. The function then calls itself whenever it finds a directory, which makes it recurse. I thought it was pretty clever; wish I'd thought of it. [ snip ] > Thanks for helping. I am experimenting and trying not to shoot myself > in the foot. So was I; that's the main reason why there are all those `echo "something"` lines - I wanted to see what it would try to do, before actually turning it loose on my files. That and the fact that doing all the conversions takes a few hours. Good luck. -- Chris Hill chris@monochrome.org ** [ Busy Expunging </> ]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1105082216190.41771>