| | #!/bin/sh |
---|
| | # renext - Mass File Rename |
---|
| | # Copyright (c) 2006, TundraWare Inc., Des Plaines, IL USA |
---|
| | # Copyright (c) 2006-2008, TundraWare Inc., Des Plaines, IL USA |
---|
| | # All Rights Reserved. Non-Commercial Use Hereby Permitted. |
---|
| | |
---|
| | RCSID="$Id: ren,v 0.101 2006/08/23 21:02:25 toor Exp $" |
---|
| | |
---|
| | RCSID="$Id: ren,v 0.102 2008/03/22 18:16:05 root Exp $" |
---|
| | |
---|
| | arg="" |
---|
| | |
---|
| | if [ $1_ = -v_ ] |
---|
| |
---|
| | echo "usage: ren [-v] oldstring newstring" |
---|
| | echo " Renames filenames containing 'oldstring' replacing with 'newstring'" |
---|
| | |
---|
| | else |
---|
| | for f in `ls -a 2>/dev/null` |
---|
| | for f in `ls -a *$1* 2>/dev/null` |
---|
| | do |
---|
| | tgt=`echo $f | sed s/${1}/${2}/` |
---|
| | tgt=`echo $f | sed s/${1}/${2}/g` |
---|
| | if [ $f != $tgt ] |
---|
| | then |
---|
| | mv ${arg} $f $tgt |
---|
| | fi |
---|
| | |