Add missing subdirectory if parent directory exists

Mostly when a new year begins
This commit is contained in:
2020-01-08 21:57:52 +01:00
parent f59bb132b0
commit 072e1d8f13

View File

@@ -19,14 +19,22 @@ fi
subDir="$myyear/" subDir="$myyear/"
thumbRoot="${piwiThumbRoot}/${subDir}" thumbRoot="${piwiThumbRoot}/${subDir}"
photoRoot="${piwiPhotoRoot}/${subDir}" photoRoot="${piwiPhotoRoot}/${subDir}"
local yearRegex='[0-9]{4}'
if [ ! -e ${thumbRoot} ] ; then if [ ! -e ${thumbRoot} ] ; then
echo "Thumbnail root ${thumbRoot} not found" if [ -w ${piwiThumbRoot} ] && [[ "$subDir" =~ $yearRegex ]] ; then
# Thumb root of piwigo available just subdir missing
echo " [I] Adding missing year subdirectory $(basename $subDir) to $piwiThumbRoot"
echo " Happy new year $(basename $subDir) I guess ;)"
mkdir -p "$thumbRoot"
else
echo " [E] Thumbnail root ${thumbRoot} not found"
exit 1; exit 1;
fi fi
fi
if [ ! -e ${photoRoot} ] ; then if [ ! -e ${photoRoot} ] ; then
echo "Photo root ${photoRoot} not found" echo " [E] Photo root ${photoRoot} not found"
exit 1; exit 1;
fi fi