Bash script generating image from video with specific title in subdirs

view story

http://askubuntu.com – I have the following bash script generating a jpg file with the same name of the video file. Now I need to change the bash script to generate the jpg file with the name image.jpg instead of with the same name of the video. I tried lots of different ways to do that but I'm not really good in bash scripting and I have some problem with the basename and subdirectories. May you please help me? #!/bin/bash for i in */*.mp4; do j=`basename $i .mp4`; /usr/bin/ffmpeg -i "$i" -r 1 -f image2 -vframes 1 -s 640x360 -ss 0:0:30 $j.jpg; done Following the directory tree / /a/video1.mp4 /b/video2.mp4 (HowTos)