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
Wrap
Text File
|
1997-11-12
|
1KB
|
65 lines
#!/bin/sh
if [ $# != 2 ] ; then
echo "Usage: $0 sourcedirectory targetdirectory" >&2
exit 1
fi
from=$1/
to=$2
rm -f /tmp/xcopy.$$
case $from in
[a-zA-Z]:*)
Source=Dos
mdir -X $from | grep '/$' >/tmp/xcopy.$$
from=`head -1 /tmp/xcopy.$$`
;;
*)
Source=Unix
from=`echo $from | sed -e 's#$#/#' -e 's#//*#/#g'`
find $from -type d -print | sed -e 's#$#/#' -e 's#//*#/#g' >/tmp/xcopy.$$
;;
esac
case $to in
[a-zA-Z]:)
:
;;
*)
to=$to/
;;
esac
case $to in
[a-zA-Z]:*)
Target=Dos
sed -e "s#^$from#$to#" -e "s#//#/#g" -e 's#\([^:]\)/$#\1#g' /tmp/xcopy.$$ | xargs mmd -sX
;;
*)
Target=Unix
sed -e "s#^$from#$to#" -e "s#//#/#g" /tmp/xcopy.$$ | xargs mkdir -p
;;
esac
echo XX
case $Source in
Dos)
for name in `cat /tmp/xcopy.$$` ; do
target=`echo $name | sed -e "s#^$from#$to#" `
mcopy "$name*" "$target"
done
;;
Unix)
for name in `cat /tmp/xcopy.$$` ; do
target=`echo $name | sed -e "s#^$from#$to#" `
mcopy $name/* "$target"
done
;;
esac
rm -f /tmp/xcopy.$$