|
发表于 2011-3-28 09:50:11
|
显示全部楼层
- #!/bin/sh
- # rename.sh
- # 批量重命名;ABC0001 ABC0002 ... ABC1000为 0001 0002 ... 1000
- # 2011-03-28
- targ_dir=$1
- if [ ! -d "$targ_dir" ]; then
- echo "Usage: ./rename.sh DIR"
- exit 1
- fi
- cd $targ_dir
- for old_file in ABC*; do
- if [ ! -f "$old_file" ]; then
- echo "$old_file is a directory"
- continue
- fi
- new_file=${old_file#ABC}
- mv -v "$old_file" "$new_file"
- done
- echo job done
- exit 0
复制代码 |
|