[SATLUG] Bash scripting noob could use some help with a Bash script

John D Choate jdchoate at gmail.com
Sun May 30 14:45:02 CDT 2010


On Sunday, May 30, 2010 08:52:43 Nate Turnage wrote:
> On Sun, May 30, 2010 at 8:13 AM, Don Davis <dondavis at reglue.org> wrote:
> 
> >
> > Using the basic version of your script:
> > for i in *wmv; do ffmpeg -i $i -ss 78.5 -s 640x352 -vframes 1 -an -f image2
> > ${i}_preview.jpg; done
> >
> > worked fine for me. I did, however, have problems using .mov files - I
> > don't know if the problem was with the .mov files or some lack of codec on
> > my part.
> 
> 
> You're right, Don. And it was the 'cat $f' that was drawing the binary in
> the terminal.
> 
> One more question. With the script the way it is, the resulting JPEG file is
> named 'filename.mov_preview.jpg' and I would like it to be just
> 'filename_preview.jpg'. How do I get that to work? How do I remove the file
> extension from $f?
> 
> Here is the revised script:
> 
> #!/bin/bash
> FILES="*.mov"
> for f in $FILES
> do
>   ffmpeg -i $f -ss 78.5 -s 640x352 -vframes 1 -an -f image2 ${f}_preview.jpg
> done
> 
> 
> Thanks again,
> 
> Nate
> 

Also, if you used 'cat > $f' then the image would get written to the $f filename and not be displayed.


More information about the SATLUG mailing list