reorganizing the repository
[project-aon.git] / common / pdf / build / check-images.sh
diff --git a/common/pdf/build/check-images.sh b/common/pdf/build/check-images.sh
new file mode 100644 (file)
index 0000000..57cb59b
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# Check if the included files are all available in the current directory
+
+file=$1
+
+if [ -z "$file" ] ; then
+    echo "Usage: $0 file.tex" 
+    echo "Checks if the included graphics in the TeX file are available in "
+    echo "the current directory"
+    exit 1
+fi
+
+if [ ! -r "$file" ] ; then
+    echo "ERROR: Cannot read $file"
+    exit 1
+fi
+
+exitval=0
+grep includegraphics $file | 
+perl -ne 'print $1."\n" if /.*\{(\w+\.pdf)\}/' |
+sort -u  | 
+while read graph; do 
+    [ ! -e "$graph" ] && echo "WARNING: Included graphic file $graph is not available in the current directory." >&2 
+    exitval=1
+done
+
+
+exit $exitval