mplayer / bash question
Dan Nelson
dnelson at allantgroup.com
Tue Dec 29 17:10:40 UTC 2009
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 at allantgroup.com
More information about the freebsd-questions
mailing list