Skip to content

Instantly share code, notes, and snippets.

@kazuhito-m
Last active December 25, 2018 02:49
Show Gist options
  • Save kazuhito-m/513b8fd56be12b0aa435ed02b5f6665d to your computer and use it in GitHub Desktop.
Save kazuhito-m/513b8fd56be12b0aa435ed02b5f6665d to your computer and use it in GitHub Desktop.
ファイル名が「先頭8文字数値」の場合にアンダーバーを付与するbashスクリプト
#!/bin/bash
# 「ファイル名の先頭が8ケタの数値」の名前のファイルに
# 数値とその次の文字の間にアンダーバーを挟んだ名前にリネームするスクリプト。
for i in $(ls | grep '^[0-9]\{8\}') ; do
newname=`echo $i | sed -e 's/^\([0-9]\{8\}\)/\1_/g'`
mv ${i} ${newname}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment