1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#!/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.$$
|