Last active
May 21, 2020 23:23
-
-
Save hata6502/9ebb9a6ce2863e9498a5ebea3a3f5c6c to your computer and use it in GitHub Desktop.
ファイルを8文字IDに名前変更します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
・使い方: 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に置き換わります。