Newer
Older
renext / ren
  1. #!/bin/sh
  2. # renext - Mass File Rename
  3. # Copyright (c) 2006-2008, TundraWare Inc., Des Plaines, IL USA
  4. # All Rights Reserved. Non-Commercial Use Hereby Permitted.
  5.  
  6. RCSID="$Id: ren,v 0.102 2008/03/22 18:16:05 root Exp $"
  7.  
  8. arg=""
  9.  
  10. if [ $1_ = -v_ ]
  11. then
  12. arg=$1
  13. shift
  14. fi
  15.  
  16. if [ $# != 2 ]
  17. then
  18. echo "usage: ren [-v] oldstring newstring"
  19. echo " Renames filenames containing 'oldstring' replacing with 'newstring'"
  20.  
  21. else
  22. for f in `ls -a *$1* 2>/dev/null`
  23. do
  24. tgt=`echo $f | sed s/${1}/${2}/g`
  25. if [ $f != $tgt ]
  26. then
  27. mv ${arg} $f $tgt
  28. fi
  29. done
  30. fi