I'm watching a folder on my synology, using a scheduled bash script (the bash script is being executed every minute), where all scanned documents are being dropped. My idea is to move them to two places, one is the paperless-ng folder and an unsorted folder, so I can move them to the correct folder by hand.
#!/bin/bash
dpath=/volume1/scanned/*
for FILE in $dpath
do
if [[ -f $FILE ]]
then
cp $FILE /volume1/unsorted_documents/
mv $FILE /volume1/docker/paperless/consume/
else
echo “There are no files in the given path.”
fi
done
This script ends up in documents being corrupt, most of the time. My thought is that it isn't finished copying before the move command is being executed.
Is there a way to make sure that the copy is done, before the move is being executed? Or another, better solution?