Skip to content

Instantly share code, notes, and snippets.

@editnuki
Created July 4, 2012 04:56
Show Gist options
  • Save editnuki/3045426 to your computer and use it in GitHub Desktop.
Save editnuki/3045426 to your computer and use it in GitHub Desktop.
引数のファイルをリネームするシェルスクリプト
#!/bin/bash
#ファイル名のtestという文字列をhogeに変更するスクリプト
NAME=$1
NAME_AFTER=$2
shift 2
for FILE in $@;do
[[ -e "$FILE" ]] || { echo "$FILE file didn't exist" ; exit 1 ; }
RENAME=`echo $FILE | sed "s/$NAME/$NAME_AFTER/g"`
mv $FILE $RENAME
done
echo "file rename ok"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment