home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / CMDS / mtools_3.6.src.lzh / MTOOLS_3.6 / SCRIPTS / xcopy < prev   
Text File  |  1997-11-12  |  1KB  |  65 lines

  1. #!/bin/sh
  2.  
  3. if [ $# != 2 ] ; then
  4.   echo "Usage: $0 sourcedirectory targetdirectory" >&2
  5.   exit 1
  6. fi
  7.  
  8.  
  9. from=$1/
  10. to=$2
  11.  
  12. rm -f /tmp/xcopy.$$
  13.  
  14. case $from in
  15.   [a-zA-Z]:*)
  16.           Source=Dos
  17.           mdir -X $from | grep '/$' >/tmp/xcopy.$$
  18.           from=`head -1 /tmp/xcopy.$$`
  19.           ;;
  20.   *)
  21.      Source=Unix
  22.      from=`echo $from | sed -e 's#$#/#' -e 's#//*#/#g'`
  23.      find $from -type d -print | sed -e 's#$#/#' -e 's#//*#/#g' >/tmp/xcopy.$$
  24.      ;;
  25. esac
  26.  
  27. case $to in
  28.   [a-zA-Z]:)
  29.          :
  30.          ;;
  31.   *)
  32.      to=$to/
  33.      ;;
  34. esac
  35.  
  36. case $to in
  37.   [a-zA-Z]:*)
  38.           Target=Dos
  39.           sed -e "s#^$from#$to#" -e "s#//#/#g" -e 's#\([^:]\)/$#\1#g' /tmp/xcopy.$$ | xargs mmd -sX
  40.           ;;
  41.   *)
  42.      Target=Unix
  43.      sed -e "s#^$from#$to#" -e "s#//#/#g" /tmp/xcopy.$$ | xargs mkdir -p
  44.      ;;
  45. esac
  46.  
  47. echo XX
  48.  
  49. case $Source in
  50.   Dos)
  51.        for name in  `cat /tmp/xcopy.$$` ; do
  52.      target=`echo $name | sed -e "s#^$from#$to#" `
  53.      mcopy "$name*" "$target"
  54.        done
  55.        ;;
  56.   Unix)
  57.        for name in `cat /tmp/xcopy.$$` ; do
  58.      target=`echo $name | sed -e "s#^$from#$to#" `
  59.      mcopy $name/* "$target"
  60.        done
  61.        ;;
  62. esac
  63.  
  64. rm -f /tmp/xcopy.$$
  65.