#!/bin/bash
# if [ -z "$1" ]; then
# echo -e "\nYou must enter the name of an avi file.\n";
# Run this script from a directory full of avi's. Watch your diskspace \
# because the end result is an mpg that's about three times the size of the avi.

for i in *.avi
do
  FILENAME=$i
  transcode -i "$i" -y ffmpeg --export_prof dvd-ntsc --export_asr 3 -o movie.tmp \
  -D0 -s2 -m movie.tmp.ac3 -J modfps=clonetype=3 --export_fps 29.97
  mplex -f 8 -o "$i".mpg movie.tmp.m2v movie.tmp.ac3
done

for file in *.mpg

do
  RMSPACES=`echo $file | sed -e "s/ /_/g"`
  mv "$file" "$RMSPACES"
done

for j in *.mpg

do
  RMAVI=`echo $j | sed -e "s/.avi//g"`
  mv "$j" "$RMAVI"
done