RedHat iTOps Tube

Wednesday, May 16, 2012

[SOLVED] Batch File Processing via Script

Hello,



I had a question about processing multiple files within a directory with a script. While I am a CS student, I have very little experience writing shell scripts. What I'd like to do is extract the audio from all video files within a directory. My current way of doing this is with ffmpeg using the command:

Code:


ffmpeg -i some_video.avi some_audio.mp3

which works fine, but I can only do one file at a time and must babysit the process.



Is there a way to say something along the lines of (in pseudocode):


Code:


#!/bin/bash



for each file in working directory

    run command 'ffmpeg -i ith_video_file.avi ith_audio_file.mp3'


?



I was thinking of somehow using wildcards, but I'm not sure how I'd go about assigning names to the extacted audio files. I'd like to have the exact same file name as the video file has (sans extension, of course). I did check this thread over here, but it was quite over my head and I'm not sure the issue was really resolved. I was also considering using pipes, but again I'm not sure how to proceed. Anyone with some pointers out there? Really gotta get up to speed with my shell scripting abilites....



Thanks in advance everyone.