exit 10;
fi
+OIHF="$IFH"
+IFH="
+"
+
+#set -x
+
if [ "$#" = "0" ] ; then
- # echo "Keine Dateien angegeben, verwende statt dessen '.'."
- FILES="."
-else
- FILES=$@
+ echo "Keine Dateien angegeben, verwende statt dessen '.'."
+ #FILES="."
+ set "."
+#else
+ #FILES=$@
fi
-OLD_DIR=""
+if [ "${OLD_DIR}" = "" ] ; then
+ OLD_DIR=".old"
+fi
-for f in $FILES ; do
- if [ -f $f ] ; then
- if [ "$OLD_DIR" = "" ] ; then
- if echo ${f} | grep "/" >/dev/null ; then
- OLD_DIR=`echo ${f} | sed 's#/[^/]*$##'`/.old
- else
- OLD_DIR=.old
- fi
- # echo "Lege Old-Dir auf '${OLD_DIR}' fest."
+#---------------------------------------------
+
+perform_file() {
+
+ F="$1"
+
+ if [ ! -f "$F" ] ; then
+ return
+ fi
+ FILEDIR=`dirname "$F"`
+ FOLDDIR="${FILEDIR}/${OLD_DIR}"
+
+ if [ ! -d "${FOLDDIR}" ] ; then
+ echo "Erstelle Verzeichnis '${FOLDDIR}' ..."
+ mkdir "${FOLDDIR}" || exit 2
+ fi
+
+ n="${FOLDDIR}/`basename ${F}`.`$DATE -r \"${F}\" '+%Y-%m-%d-%H-%M-%S'`"
+ echo " - '${F}' -> '$n'"
+ cp -p "${F}" "${n}"
+
+}
+
+#---------------------------------------------
+
+perform_dir() {
+
+ D="$1"
+
+ echo "Sichere Verzeichnis '${D}' ..."
+ # sleep 1
+
+ for NODE in `ls -1 -d "${D}"/* "${D}"/.* 2>/dev/null` ; do
+
+ # echo "Untersuche Node '${NODE}' ..."
+ BASENAME=`basename "${NODE}"`
+ # echo "Basename: '${BASENAME}'"
+ # sleep 1
+
+ SKIP=0
+
+ if [ "${BASENAME}" = "." ] ; then
+ SKIP=1
+ fi
+
+ if [ "${BASENAME}" = ".." ] ; then
+ SKIP=1
+ fi
+
+ if [ "${BASENAME}" = "${OLD_DIR}" ] ; then
+ SKIP=1
fi
- if [ ! -d $OLD_DIR ] ; then
- echo "Erstelle Verzeichnis '${OLD_DIR}' ..."
- mkdir ${OLD_DIR} || exit 2
+
+ if [ -L "${NODE}" ] ; then
+ SKIP=1
fi
- n="${OLD_DIR}/`basename ${f}`.`$DATE -r $f '+%Y-%m-%d-%H-%M-%S'`"
- echo " - $f -> $n"
- cp -p $f $n
- elif [ -d $f ] ; then
- if [ "${f}" = "." -o "${f}" = ".." ] ; then
- # echo "Sichere Verzeichnis '${f}' ..."
- LIST_PATTERN="${f}/.* ${f}/*"
- LIST=""
- for ff in $LIST_PATTERN ; do
- if [ -f ${ff} ] ; then
- LIST="$LIST ${ff}"
- elif [ -d ${ff} ] ; then
- DIRNAME=`basename ${ff}`
- if [ "${DIRNAME}" != "." -a "${DIRNAME}" != ".." -a "${DIRNAME}" != ".old" ] ; then
- LIST="$LIST ${ff}"
- fi
- fi
- done
- $0 $LIST
- else
- DIRNAME=`basename ${f}`
- if [ "${DIRNAME}" != "." -a "${DIRNAME}" != ".." -a "${DIRNAME}" != ".old" ] ; then
- echo "Sichere Verzeichnis '${f}' ..."
- $0 ${f}/.* ${f}/*
+
+ if [ "${SKIP}" = "0" ] ; then
+
+ if [ -d "${NODE}" ] ; then
+ perform_dir "${NODE}"
+ elif [ -f "${NODE}" ] ; then
+ perform_file "${NODE}"
fi
+
fi
+
+ done
+
+}
+
+#---------------------------------------------
+
+perform_node() {
+
+ N="$1"
+
+ if [ -L "$N" ] ; then
+ return
+ fi
+
+ if [ -d "$N" ] ; then
+ perform_dir "$N"
+ return
+ fi
+
+ if [ -f "$N" ] ; then
+ perform_file "$N"
fi
+
+}
+
+while [ "$#" != "0" ] ; do
+ perform_node "$1"
+ shift
done
+IHF="${OIFH}"
+
+exit 0
+
+#---------------------------------------------
+