restructure files into directories by year and "Misc" to ease testing with current...
[fw/tmflights] / Misc / fixeeprom
diff --git a/Misc/fixeeprom b/Misc/fixeeprom
new file mode 100755 (executable)
index 0000000..82ecaf1
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+for i in "$@"; do
+    num=`grep '^F' "$i" | awk '{printf ("%03d\n", strtonum("0x" $4))}'`
+    case "$num" in
+       "")
+       echo "$i: no flight number found" 1>&2
+       ;;
+       *)
+       newname=`echo "$i" | sed 's/flight-[0-9][0-9][0-9]/flight-'"$num"'/'`
+       echo $num "$i" "$newname"
+       ;;
+    esac
+done | sort -rn | sed 's/^[0-9][0-9]*//' | while read old new; do
+    if [ $new = $old ]; then
+       :
+    else
+       if [ -f $new ]; then
+           if cmp $new $old; then
+               echo "$old is a duplicate of $new"
+               rm $old
+           else
+               echo "$old: $new already exists"
+           fi
+       else
+           echo mv $old $new
+       fi
+    fi
+done
\ No newline at end of file