After a long time using the first version, I realize that it take a long time to finish its task. So I decide to change it. And here is my second version, it’s better than the older one.
#!/bin/bash
#This bash script is using to split movie into multiple viewable parts. Give it the execute permission and then enjoy it
#Written by bornbygoogle. Any question please let me know at bornbygoogle@yahoo.com or at hackthefreedom.blogspot.com.
ARGS=2
E_MAUVAISARGS=65
if [ $# -ne "$ARGS" ]
then
echo “Usage: `basename $0` directory_which_content_all_the_film_you_want_to_split time_length_of_each_part_in_seconds”
exit $E_MAUVAISARGS
fi
cd $1
ls | grep avi > 002.txt
sed ’s/.avi//g’ 002.txt > 001.txt
rm 002.txt
echo “List of films : “
cat 001.txt
i=1
size=1000001
time=0
echo “Start to split !”
cat 001.txt | while read line; do
while [ $size -gt 1000000 ]
do
echo “Episode $i – film $line”
mencoder -ss $time -endpos $2 -ovc copy -oac copy $line.avi -o $line-part$i.avi
echo “Finished split episode $i”
let size=`cat $line-part$i.avi | wc -c`
let i++
let time=$time+$2-10
done;
let i–
rm $line-part$i.avi
let size=1000001
let i=1
let time=0
done
echo “Finished ! Have fun !”
rm 001.txt






