1
0
mirror of https://github.com/aquatix/dotfiles.git synced 2025-12-06 20:35:11 +01:00

Archive all files from a certain directory

This commit is contained in:
2016-03-31 14:54:36 +02:00
parent 8bf3a8bf21
commit 7b49b4129a

28
bin/archive_all Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "No sourcedir provided"
exit 1
elif [ -z "$2" ]; then
echo "No archive directory path provided"
exit 2
elif [ -z "$3" ]; then
echo "No normalised filename provided"
exit 3
fi
SOURCEDIR="${1}"
ARCHIVEDIR="${2}"
FILENAME="${3}"
if [ ! -e $SOURCEDIR ]; then
echo "$SOURCEDIR does not exist, exiting"
exit 4
fi
for FILE in $(ls -1 $SOURCEDIR); do
if [ ! -d "${SOURCEDIR}/${FILE}" ]; then
echo $FILE
archive_file "${SOURCEDIR}/${FILE}" "${ARCHIVEDIR}" "${FILENAME}"
fi
done