fixup_filenames.sh 317 B

12345678910111213141516171819
  1. #!/bin/sh
  2. set -e
  3. if [ ! -d "$1" ] ; then
  4. echo "I need a directory"
  5. exit 1
  6. fi
  7. for fn in "$1"/* ; do
  8. prev=`basename "$fn"`
  9. post=`sha256sum "$fn" | sed -e 's/ .*//;'`
  10. if [ "$prev" == "$post" ] ; then
  11. echo "OK $prev"
  12. else
  13. echo "mv $prev $post"
  14. mv "$fn" "$1/$post"
  15. fi
  16. done