Linux‎ > ‎QNAP NAS‎ > ‎

Check for empty directory

script: check for empty folders/directory 

Example:
one directory as root have many subfolders, in subfolders every day IP camera ( every camera has different folder ) send jpg pictures and every night script move all jpg files to another directory on HDD and sort by date.
every now and then camera stops recording pictures in her folder and with the script below I can check for empty subfolders, script send an email, and fix that camera that is out of order.

#! /bin/bash

################################
PATH="/share/CamActive/"
################################

BROJDIR="0"

BROJDIR=`/share/MD0_DATA/.qpkg/Optware/bin/findutils-find $PATH -type d -empty  | tee /share/CamActive/emptyfolders.txt |  wc -l`

if [ $BROJDIR != "0" ]
    then
    #salji mail
MAIL="mail"
echo "Subject: emptyfolders" > $MAIL
echo "From: events@mail.com" >> $MAIL
echo "To: kruno@mail.com" >> $MAIL
echo "" >> $MAIL
cat /share/CamActive/emptyfolders.txt >> $MAIL
echo "" >> $MAIL
cat $MAIL | sendmail -t
fi
Comments