#!/bin/sh ## ## SCRIPT NAME: file-identify_aniGIF.sh ## ##+####### ## PURPOSE: ## For a file-type string (such as 'GIF') passed in the first argument ($1) ## and a filename passed in the second argument ($2), this script uses ## 1) the 'file' command to determine if the file is the specified file-type ## and ## 2) if so, then uses the ImageMagick 'identify' command determine ## whether the GIF file is an animated-GIF file. ## ## If the filename IS an animated-GIF, the filename is echoed to stdout. ## Otherwise, nothing is sent to stdout. ## ## This shell script is meant to be issued from a shell script ## 'findAniGIFfiles_forCriteria.sh'. ## That shell script calls this script in a 'find' command. ## ##+######################################################################### ## MAINTENANCE HISTORY: ## Started by: Blaise Montandon 2014may01 ## Updated by: Blaise Montandon 2014 ##+######################################################################### ## FOR TESTING: (to show statements as they execute) # set -x FILEtype="$1" INfile="$2" ##+########################################################## ## Use the 'file' and 'identify' commands to determine ## whether 'INfile' is an animated-GIF file. ##+########################################################## ## Example output from the 'file' command on a GIF file: ## $ file file_middle_name.gif ## file_middle_name: GIF image data, version 89a, 444 x 175 ## ## So we can look for 'GIF' after the colon character. ##+######################################################### ## Example output from the 'identify' command on a GIF file: ## identify file_middle_name.gif ## file_middle_name.gif GIF 1024x768 1024x768+0+0 8-bit PseudoClass 256c 208kb ##+############################################################################## ## Example output from the 'identify' command on an animated-GIF file: ## $ identify file_middle_name_ani.gif ## file_middle_name_ani.gif[0] GIF 444x175 444x175+0+0 8-bit PseudoClass 32c 4.28kb ## file_middle_name_ani.gif[1] GIF 16x18 444x175+49+46 8-bit PseudoClass 32c 4.28kb ## etc. for each 'scene' in the animated-GIF file. ## ## So we can look for '[0]' in the first line of output from 'identify'. ##+############################################################################## ## FOR TESTING: (to show statements as they execute) # set -x GIFfilename=`file "$INfile" | grep ":.*$FILEtype" | cut -d: -f1` if test "$GIFfilename" = "" then exit fi ANIGIFcheck=`identify "$GIFfilename" | head -1 | grep '\[0\]'` if test "$ANIGIFcheck" = "" then exit else echo "$GIFfilename" fi