Last active
January 2, 2018 17:45
-
-
Save hlapp/dbaa5baf2f6275887af2dba36b3dc167 to your computer and use it in GitHub Desktop.
Moves files from a source directory to a destination directory, one at a time, with a delay, which extends when the destination directory accumulates files. One use-case is feeding a large number of files into a spool directory where they get processed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
src=${1:-.} | |
dest=$2 | |
if [ -z "$dest" ] ; then | |
dest="$1" | |
fi | |
ls -f "$src" | \ | |
while read f ; do | |
if [ -d "$src/$f" ] ; then | |
continue | |
fi | |
# echo "mv $src/$f $dest" | |
mv "$src/$f" "$dest" | |
sleep 3 | |
spooled=$(ls -f "$dest" | wc -l) | |
if [ $spooled -gt 50 ] ; then | |
sleep 90 | |
elif [ $spooled -gt 30 ] ; then | |
sleep 30 | |
elif [ $spooled -gt 7 ] ; then | |
sleep 10 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment