Skip to content

Instantly share code, notes, and snippets.

@hata6502
Last active May 21, 2020 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hata6502/9ebb9a6ce2863e9498a5ebea3a3f5c6c to your computer and use it in GitHub Desktop.
Save hata6502/9ebb9a6ce2863e9498a5ebea3a3f5c6c to your computer and use it in GitHub Desktop.
ファイルを8文字IDに名前変更します。
#!/bin/bash -eu
while [ $# -ne 0 ]
do
if [[ $1 =~ ^[0-9a-f]{8}\. ]]; then
shift
continue
fi
hashed=`crc32 <(echo $1)`.${1##*.}
echo $1' -> '${hashed}
mv -i "$1" "${hashed}"
shift
done
@hata6502
Copy link
Author

hata6502 commented Apr 28, 2019

・使い方: mvhash (名前変更するファイル)...

・使用例:
$ ls
46c77704.png
715f1a5d.png
'Screenshot from 2019-04-27 12-12-51.png'
'Screenshot from 2019-04-27 14-09-11.png'
'Screenshot from 2019-04-28 00-58-31.png'
publicdomain
$ mvhash *.png
Screenshot from 2019-04-27 12-12-51.png -> baf6fe90.png
Screenshot from 2019-04-27 14-09-11.png -> cc138a80.png
Screenshot from 2019-04-28 00-58-31.png -> 20c665c9.png

このように Screenshot*.png ファイルが8文字IDに置き換わります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment