fixup_filenames.sh 318 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
#!/bin/sh

set -e

if [ ! -d "$1" ] ; then
    echo "I need a directory"
    exit 1
fi

for fn in "$1"/* ; do
11
12
13
    prev=$(basename "$fn")
    post=$(sha256sum "$fn" | sed -e 's/ .*//;')
    if [ "$prev" = "$post" ] ; then
14
15
16
17
18
19
      echo "OK $prev"
    else
      echo "mv $prev $post"
      mv "$fn" "$1/$post"
    fi
done