#!/bin/bash
DATE=$(date +%Y-%m-%d-t-%H-%M-%S)
if [[ $1 = --help ]]; then
echo USAGE:
echo './zip.sh /<fromdir> <to-subdir> - subdir will be not zipped'
echo './zip.sh /<fromdir> /<to-dir> - zipping <fromdir> to /<full_path_to_dir>'
else
arch_fld=$1
#if [$arch_fld = '--help']; then
if ! [ -z $1 ] && ! [ -z $2 ] ; then
for folder in $arch_fld/*
do
if [[ $2 = /* ]]; then
if ! `file $folder | grep -i -P $2'|'$RECYCLE.BIN'|System' > /dev/null 2>&1`; then
save_path=${folder//$arch_fld/$2"/"$DATE}
echo -'*Achiving folder - ' $folder ' to '$save_path'.zip *-'
7z a -tzip -ssw -mx7 "$save_path.zip" "$folder"
fi
else
if ! `file $folder | grep -i -P $2'|'$RECYCLE.BIN'|System' > /dev/null 2>&1`; then
save_path=${folder//$arch_fld/$arch_fld"/"$2"/"$DATE}
echo -'*Achiving folder - ' $folder ' to '$save_path'.zip *-'
7z a -tzip -ssw -mx7 "$save_path.zip" "$folder"
fi
fi
done
else
echo Not enouth parametrs! Try --help
fi