I have a huge collection of videos that all need to be converted into mp4. The folder structure is like this
Events
  Chicago
  Boston
  San Fran
  London Expo
Inside each event holds all of videos in either avi format or .mkv. I want them to be converted to the same file name. but with the mp4 extension.
My question is how do I loop through a folders sub folders, and also keep the file names because at the moment they have spaces in them.. Here is what I have at the moment.
sourcedir="$1"
destdir="$2"
cd "$sourcedir"
for i in `ls`; do
  HandBrakeCLI -i "$i" -o "$destdir/${i%.*}.mp4" --preset="AppleTV"
  echo $i
done
Phillips Code:
cd "$sourcedir"
echo "Directory: $sourcedir"
destdir = sourcedir
for subdir in *
do
  if [[ -d "$subdir" ]]
  then
    for file in "$subdir"/*
    do
      HandBrakeCLI -i "$file" -o "${file%.*}.mp4" --preset=AppleTV
      echo "$file"
    done
  fi
done