# check if any program has finished transferring and ready for a run shopt -s nullglob for file in /opt/autorun/awaiting/* do echo "now handling $file" mv "$file" /opt/autorun/autorun.py if [ -f "/opt/autorun/autorun.py" ] then python /opt/autorun/autorun.py rm /opt/autorun/autorun.py fi done