Date: Tue, 29 Dec 2009 11:10:38 -0600 From: Dan Nelson <dnelson@allantgroup.com> To: Neil Short <neshort@yahoo.com> Cc: freebsd-questions@freebsd.org Subject: Re: mplayer / bash question Message-ID: <20091229171038.GJ98917@dan.emsphone.com> In-Reply-To: <793133.83739.qm@web56501.mail.re3.yahoo.com> References: <793133.83739.qm@web56501.mail.re3.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Dec 29), Neil Short said:
> I'm trying to batch-rip audio files from a bunch of video files.
>
> I have a directory full of *.vob files:
>
> ls *.vob
> 01.vob 03.vob 05.vob 07.vob 09.vob 11.vob 13.vob
> 02.vob 04.vob 06.vob 08.vob 10.vob 12.vob
>
> So I wrote a little command line script to rip wave files from all the
> vob's:
>
> > ls *.vob |
> > while read f
> > do
> > mplayer -ao pcm:file=`basename $f .vob`.wav $f
> > done
>
> the first 01.wav file is created successfully; but then the whole sh'bang
> exits without ripping the rest of the vob's:
Try this instead:
for f in *.vob ; do
mplayer -ao pcm:file=${f%.vob}.wav $f
done
Uses the shell's native file globbing to expand the *.vob wildcard, and the
shell's native string processing functions to remove a suffix. If that
still doesn't work, run the script with "sh -x" to turn debugging on, and
see what your variables are expanding to as the script runs.
--
Dan Nelson
dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091229171038.GJ98917>
