#!/bin/bash # # Image template creator and thumbnail maker. # # USAGE: ./make_lazy $CUSTOM_TITLE_NAME # If CUSTOM_TITLE_NAME is blank, it will use the actual filename # (with underscores and all). # Currently supported formats are .png and .jpg. # # In addition to most normal linux apps, this script will # require the ImageMagick suit for thumbnail creation. # You can find it here http://www.imagemagick.org/script/index.php # first, check to see if we will use a custom name for the title. if [ ! "$1" ]; then echo "Custom title name not defined." echo "Using actual filename instead." fi # nuke blank spaces rename 'y/ /_/' * # make all folders and filenames lowercase # first, rename all folders (lazy kang from another one of my scripts) for f in `find . -depth ! -name CVS -type d`; do g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'` if [ "xxx$f" != "xxx$g" ]; then echo "Renaming folder $f" mv -f "$f" "$g" fi done # now, rename all files for f in `find . ! -type d`; do g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'` if [ "xxx$f" != "xxx$g" ]; then echo "Renaming file $f" mv -f "$f" "$g" fi done # make the html and paste into the output file. ls *.png *.jpg | while read line; do if [ ! "$1" ]; then name=`echo $line | cut -f1 -d "."` else name="$1" fi extension=`echo $line | cut -f2 -d "."` filename=`echo $line | cut -f1 -d "."` (cat << EOF) >> output.html $name EOF done mkdir .thumbs find . ! -name '*.html' ! -name 'khas_is_a_slacker.sh' ! -name '.thumbs' | xargs -i cp {} .thumbs cd .thumbs mogrify -resize 200x200 *.* # add the _small suffix ls | while read line; do extension=`echo $line | cut -f2 -d "."` filename=`echo $line | cut -f1 -d "."` mv $line ../"$filename"_thumb.$extension done # cleanup cd .. rm -rf .thumbs echo "conversion complete..."