Hello all,
I have this Shell script and I've managed to muck it up and I was hoping I could be corrected and put on the right path and hopefully add a few things that I am not competent enough to do myself. I have put what I want do as comments in the Shell script below.
#!/bin/bash
#Get all files from dir "videos" and send to processLine function one at a time
cd /home/test/videos/
for file in `dir -d *` ; do
processLine -f $file
done
processLine(){
# I was hoping to have a further for loop that would loop 4 times and change the $ext
#variable to avi, mpg, wmv and mov
#For loop, execute a command on each file
for i in 1 2 3 4 5 6 7 8 9 10
do
START=$(date +%s.%N)
echo "$line"
#The saved file in done dir should have filename as $file + START.
eval "ffmpeg -i $file -ar 44100 /home/test/videos/done/$fileSTART.$ext" > /dev/null 2>&1
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
echo "$line, $START, $END, $DIFF" >> file.csv 2>&1
echo "It took $DIFF seconds"
echo $line
done
}
Basic idea of the script is to: Get all files from dir and run an ffmpeg command on them and see how long it takes. I am trying to collect some stats
Thank you for any help
Update
Making use of Juliano's script and swapping for loops 2 and 3. I have managed to get this output below:
.
.
.
/home/test/videos/done 8 mov took 0.012 seconds
/home/test/videos/done 9 mov took 0.012 seconds
/home/test/videos/video1236104961.flv 0 avi took 0.446 seconds
It pauses there.