#!/bin/bash
# make_thumbs v0.0.2
# Script que genera thumbnails de todas las películas en el directorio Media
# Copyright Santi Noreña 2012-2013
# GPL License
cd $1 ||{
   echo "Can not change to directory." $1
   exit $E_XCD;
}
cd video
for folder in $(find -maxdepth 1 -type d); do
		rm $folder/thumbs/*
		mkdir $folder/thumbs	
	done
for file in $(find . -maxdepth 2 -mindepth 2 -type f ); do 
		avconv -i $file -f image2 -frames:v 1 -s 64x46 -vcodec mjpeg $file.jpg
	done
for folder in $(find -maxdepth 1 -type d); do
		mv $folder/*.jpg $folder/thumbs
	done
exit 0
