Skip to content

Instantly share code, notes, and snippets.

@syui
Created May 6, 2014 08:32
Show Gist options
  • Save syui/11556151 to your computer and use it in GitHub Desktop.
Save syui/11556151 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# == 1 ];then
case $1 in
-[hH]|--[hH]elp)
cat << EOF
フォルダ内の一括リネーム
$ rename <type>
更新日時順
$ rename <type> -t
EOF
;;
*)
type=$1
a=1
for i in `ls -t *.$type`; do
new=$(printf "%03d.$type" ${a})
mv "${i}" ${new}
let a=a+1
done
;;
esac
else
if [ $# == 2 ];then
case $2 in
-t)
type=$1
a=1
for i in `ls -t *.$type`; do
new=$(printf "%03d.$type" ${a})
mv "${i}" ${new}
let a=a+1
done
;;
*)
echo "オプションは<-t>を指定してください"
;;
esac
else
echo "ファイルタイプ<type>を指定してください"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment