38 lines
718 B
Plaintext
38 lines
718 B
Plaintext
|
#!/bin/bash
|
||
|
# wut-rm-random
|
||
|
#
|
||
|
# Does a coin flip to decide whether to remove a file or not.
|
||
|
# Runs on directory specified below.
|
||
|
#
|
||
|
# XXX This script removes files and directories in data/ !!! XXX
|
||
|
#
|
||
|
# Usage:
|
||
|
# wut-rm-random
|
||
|
# Example:
|
||
|
# wut-rm-random
|
||
|
|
||
|
# NOTE:
|
||
|
# In current unvetted-CW-8k dir:
|
||
|
# 129*-132* = good
|
||
|
# 133*-135* = bad
|
||
|
|
||
|
# Number of waterfalls to keep:
|
||
|
KEEP=5000
|
||
|
|
||
|
# XXX Delete data in this directory! XXX
|
||
|
cd data/test/unvetted/ || exit
|
||
|
|
||
|
TOTALFILES=`ls waterfall_*.png | wc -l`
|
||
|
for wf in waterfall_*.png
|
||
|
do \
|
||
|
if [ $TOTALFILES -gt $KEEP ] ; then
|
||
|
RANDFLIP=`echo $((0 + RANDOM % 2))`
|
||
|
if [ $RANDFLIP = 1 ] ; then
|
||
|
rm -f $wf
|
||
|
fi
|
||
|
let TOTALFILES=`ls waterfall_*.png | wc -l`
|
||
|
else break
|
||
|
fi
|
||
|
done
|
||
|
|