X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=Misc%2Ffixeeprom;fp=Misc%2Ffixeeprom;h=82ecaf18b496c52679f045abff7689db6e637e13;hb=b7adf88eaf34060be679b93d0761d345543e3e97;hp=0000000000000000000000000000000000000000;hpb=77b1bf3a9c62d0ffe73be18905e26e5f8087ec4a;p=fw%2Ftmflights diff --git a/Misc/fixeeprom b/Misc/fixeeprom new file mode 100755 index 0000000..82ecaf1 --- /dev/null +++ b/Misc/fixeeprom @@ -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