I have a requirement to process a folder full of files (converting .avi to .mp2 and .m1v, as it happens, en route to DVD authoring). To convert a single file I use the command line
lav2wav +p foo.avi | mp2enc -V -o foo.mp2
I find the whole area of regular expressions etc confusing; is there a kind expert who could show how to get the above to work for all the files in a folder, such as
for name in *.avi do (How would I do the above with each file?) done
In particular, how do I match just the filename and leave off the extension?
-- GT
On 2004-01-24 23:00:42 +0000 Graham Trott gt@pobox.com wrote:
lav2wav +p foo.avi | mp2enc -V -o foo.mp2
I find the whole area of regular expressions etc confusing; is there a kind
No regular expressions required. This is a search and replace for bash.
expert who could show how to get the above to work for all the files in a folder, such as
for name in *.avi do (How would I do the above with each file?)
lav2wav +p $name | mp2enc -V -o ${name/%avi/mp2}
done
In particular, how do I match just the filename and leave off the extension?
In general, you can use the basename command to do that, but using bash's replace is faster for your problem (no extra processes needed).
; basename test.c .c test