zshrc: Move exirename to its own file
[grml-etc-core.git] / usr_share_grml / zsh / functions / exirename
diff --git a/usr_share_grml/zsh/functions/exirename b/usr_share_grml/zsh/functions/exirename
new file mode 100644 (file)
index 0000000..2ab3b62
--- /dev/null
@@ -0,0 +1,18 @@
+# Rename pictures based on information found in exif headers
+emulate -L zsh
+
+if [[ $# -lt 1 ]] ; then
+    echo 'Usage: jpgrename $FILES' >& 2
+    return 1
+else
+    echo -n 'Checking for jhead with version newer than 1.9: '
+    jhead_version=`jhead -h | \
+                   grep 'used by most Digital Cameras.  v.*' | \
+                   awk '{print $6}' | tr -d v`
+    if [[ $jhead_version > '1.9' ]]; then
+        echo 'success - now running jhead.'
+        jhead -n%Y-%m-%d_%Hh%M_%f $*
+    else
+        echo 'failed - exiting.'
+    fi
+fi