comparison bin/putcrc @ 79:08d5f6023998

Replace checksum calculator with python version.
author Edho Prima Arief <me@myconan.net>
date Sat, 09 Jul 2011 15:33:37 +0700
parents 94ee419ad047
children
comparison
equal deleted inserted replaced
78:06fd72a78cc1 79:08d5f6023998
22 if [ -f "${file}" ] && [ -r "${file}" ] && [ -n "$(printf "%s\n" "${file}" | sed -e 's/.*[A-F0-9]\{8\}.*//')" ]; then 22 if [ -f "${file}" ] && [ -r "${file}" ] && [ -n "$(printf "%s\n" "${file}" | sed -e 's/.*[A-F0-9]\{8\}.*//')" ]; then
23 filename="$(basename "$(safe_path "${file}")")" 23 filename="$(basename "$(safe_path "${file}")")"
24 dirname="$(dirname "$(safe_path "${file}")")" 24 dirname="$(dirname "$(safe_path "${file}")")"
25 myfile="$(printf "%s\n" "${filename%.*}" | sed -e 's/\([^]]\)$/\1 /')" 25 myfile="$(printf "%s\n" "${filename%.*}" | sed -e 's/\([^]]\)$/\1 /')"
26 myext="${filename##*.}"; if [ "${myext}" = "${filename}" ]; then myext=""; else myext=".${myext}"; fi 26 myext="${filename##*.}"; if [ "${myext}" = "${filename}" ]; then myext=""; else myext=".${myext}"; fi
27 crc=$(cek.rb "$(safe_path "${file}")" | tail -1 | sed -e 's/.*\([A-F0-9]\{8\}\)$/\1/') 27 crc=$(cek.py "$(safe_path "${file}")" | tail -1 | sed -e 's/.*\([A-F0-9]\{8\}\)$/\1/')
28 mv -- "${file}" "${dirname}/${myfile}[${crc}]${myext}" && printf "%s => %s\n" "${file}" "${myfile}[${crc}]${myext}" 28 mv -- "${file}" "${dirname}/${myfile}[${crc}]${myext}" && printf "%s => %s\n" "${file}" "${myfile}[${crc}]${myext}"
29 else 29 else
30 printf "%s\n" "${file} is not a file or unreadable" 30 printf "%s\n" "${file} is not a file or unreadable"
31 fi 31 fi
32 done 32 done