# This program examines a group of filenames based on extension [e.g. .tif # files] and tests to see if an equivalent file of type .??? exists [where # .??? is the extension inputted by the user]. If no match is found, then the # program will output the directory and filename to screen and to the file # /home/xxxx/tmp/compare.txt [where xxxx is the users home directory]. # This module creates the variables home and current_directory. pwd | read current_directory cd pwd | read home cd ${current_directory} # This module creates a tmp directory in the home directory of the user if one # does not already exist. This program needs to be used in conjunction with # the program home-directory. if test -d ${home}/tmp then print "\n\ntmp directory already exists" else mkdir ${home}/tmp fi # Program Content Starts Here tput clear print "Enter the file extension for the reference images [e.g. tif]:\c" read testdefault print "\nEnter the file extension for the derivative images [e.g. gif]:\c" read testtype print "You compared .${testtype} files to .${testdefault} files" > ${home}/tmp/compare.txt print "The Following Files are MISSING in:" >> ${home}/tmp/compare.txt tput clear print " How many feature codes do your .${testdefault} files contain (enter 0 for none)? \c" read numfeatcodes print " Do your .${testtype} files contain a feature code(s)? If yes, enter the letter or letters that make up the feature code (e.g. r, t, z, rt, .etc); If no, then just press the return key: \c" read featurecode tput clear print " MENU c) Search current directory only r) Search recursively CHOICE ==> \c" read answer case ${answer} in # Current directory only c) print "The Following Files are Missing in:" print "\n$(pwd)" | tee -a ${home}/tmp/compare.txt for i in $(ls -1 *\.${testdefault}) do print "${i}" | cut -d"." -f1 | wc -c | read charcount let charcount-=1 # print "character count = ${charcount}" numchars=$(expr ${charcount} - ${numfeatcodes}) # print "number of characters = ${numchars}" # print "character count (${charcount}) minus feature code (${numfeatcodes}) = ${numchars}" print "${i}" | cut -c1-${numchars} | read filename if ! test -f ${filename}${featurecode}.${testtype} then print "${filename}${featurecode}.${testtype}" | tee -a ${home}/tmp/compare.txt fi done ;; # Recursive search r) print "The Following Files are Missing in:" for j in $(find . -type d -print) do cd ${current_directory}/${j} print "\n$(pwd)" | tee -a ${home}/tmp/compare.txt for i in $(ls -1 *\.${testdefault}) do print "${i}" | cut -d"." -f1 | wc -c | read charcount let charcount-=1 # print "character count = ${charcount}" numchars=$(expr ${charcount} - ${numfeatcodes}) # print "number of characters = ${numchars}" # print "character count (${charcount}) minus feature code (${numfeatcodes}) = ${numchars}" print "${i}" | cut -c1-${numchars} | read filename if ! test -f ${filename}${featurecode}.${testtype} then print "${filename}${featurecode}.${testtype}" | tee -a ${home}/tmp/compare.txt fi done done ;; # Error Routine *) print "not a valid input" read ;; esac print "\nA report file was saved as: ${home}/tmp/compare.txt"