1#!/bin/bash 2 3# find_missing_descs.sh 4 5 6# This simple shell script looks for all stamps (PNG or SVG files) 7# and reports which ones seem to lack a description (a corresponding TXT file). 8 9# NOTE: It simply lists the names of the missing TXT files, 10# rather than listing the PNGs or SVGs that lack TXT files. 11 12# Bill Kendrick <bill@newbreedsoftware.com> 13# 2007.02.15 - 2007.02.15 14 15 16# "strstr()" function, from 17# http://www.linuxvalley.it/encyclopedia/ldp/guide/abs/contributed-scripts.html 18# By Noah Friedman 19 20function strstr () 21{ 22 # if s2 points to a string of zero length, strstr echoes s1 23 [ ${#2} -eq 0 ] && { echo "$1" ; return 0; } 24 25 # strstr echoes nothing if s2 does not occur in s1 26 case "$1" in 27 *$2*) ;; 28 *) return 0;; 29 esac 30 31 # use the pattern matching code to strip off the match and everything 32 # following it 33 first=${1/$2*/} 34 35 # then strip off the first unmatched portion of the string 36 return 1; 37} 38 39 40# Find all PNGs and SVGs 41for i in `find ../stamps -name "*.png" -o -name "*.svg"` 42do 43 # Grab path of this file (because it's lost by basename) 44 path=`dirname $i` 45 46 # Call basename twice to yank off both .svg and .png from the end 47 base=`basename "$i" .png` 48 base=`basename "$base" .svg` 49 50 # Ignore mirror and flip files (they use the main file's .txt file) 51 strstr "$base" _mirror 52 if [ $? -eq 1 ]; then { continue; } fi 53 54 strstr "$base" _flip 55 if [ $? -eq 1 ]; then { continue; } fi 56 57 # See if this file has a corresponding .txt description file 58 txt="$path/$base.txt" 59 60 if [ ! -f "$txt" ]; then { 61 echo "$txt"; 62 } fi 63done 64