Code:
#!/bin/bash
# FILE : bbapcom
# Function: Appends (adds too) comments to all .jpg images in the directory.
# Copyright (C) 2006-2009 Dave Crouse <crouse@usalug.net>
# ------------------------------------------------------------------------ #
if [[ $1 = "--help" || $1 = "-h" || $1 = "help" ]]; then
echo " Function: Appends (adds too) comments to all .jpg images in the directory.";
echo " Usage: $0 \"comment inside of quotation marks ! \" ";
echo " Requires: wrjgpcom";
echo " EXAMPLE: $0 \"My comment goes here\" ";
echo " Note, you MUST include the quotation marks around the comment";
echo " or the command will fail to perform as expected.";
echo " ";
echo " Comments/Suggestions/Bugfixes to <crouse@usalug.net>";
echo " USA Linux Users Group - http://usalug.org";
echo " ";
exit 0
fi
if [[ -z $( type -p wrjpgcom ) ]]; then echo -e "The program wrjpgcom -- NOT INSTALLED !";exit ;fi
if [ -z "$1" ] ; then
echo " ";
echo " ######### COMMAND FAILED ########## ";
echo " USAGE: $0 \"comment inside of quotation marks ! \" ";
echo " EXAMPLE: $0 \"My comment goes here\" ";
echo " Note, you MUST include the quotation marks around the comment";
echo " or the command will fail to perform as expected.";
echo " ######### COMMAND FAILED ########## ";echo " ";
else
export IFS=$'\n';
for i in $(find . -maxdepth 1 -type f -iname "*.jpg");
do
echo "Adding comment to" ${i:2}; wrjpgcom -comment "$1" ${i:2} > _${i:2} ; mv _${i:2} ${i:2};
done
fi
exit 0