home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / shell / SKsh017.lzh / scr_source / chext.s next >
Encoding:
Text File  |  1991-04-14  |  722 b   |  36 lines

  1. #!c:sksh
  2.  
  3. #*************************************************************************
  4. # This function renames files to a new extention
  5. #*************************************************************************
  6.  
  7. local _fspec _oldbase _newsuffix
  8.  
  9. if [ $# -lt 2 -o "$1" = '-?' ]
  10. then
  11.    echo 'Usage:' $(basename $0) 'newext files...'
  12.    echo '       (renames files with new extention)'
  13.    return 1
  14. fi
  15.  
  16. _newsuffix="$1"
  17.  
  18. if [ -z $(car "$_newsuffix" '.') ]
  19. then
  20.    _newsuffix=$(cdr "$_newsuffix" '.')
  21. fi
  22.  
  23. shift
  24.  
  25. for _fspec in $*
  26. do
  27.    if [ ! -f "$_fspec" ]
  28.    then
  29.       echo -c $(basename $0) ": $_fspec not found, skipping."
  30.    else
  31.       _oldbase=$(extname -v "$_fspec")
  32.       mv "$_fspec" "$_oldbase.$_newsuffix"
  33.    fi
  34. done
  35.  
  36.