In my shop we have security cameras that save images to one of our servers. The images are stored in this format:
HH_MM_SS.jpg
We end up with 2-3 images per second stored on the server during busy times. While having such a detailed record is great, it bogs things down when I try to browse through the pictures to see what was going on at a given time. I wrote this script to get the first image from the first second of every minute during the day and copy it to another folder:
Code:
cd $1 #change directory to the first argument given
LIMIT=23 # 24 hours in a day
for ((a=0; a <= LIMIT ; a++))
do
#pad the string if need be
if [ ${#a} -eq 1 ]
then
b=0$a;
else
b=$a
fi
#make a directory if necessary
if [ -e "$b" ]
then
echo $b exists
else
mkdir $b
fi
echo $b\*
# move all files from this hour to the hour's directory
mv $b\* $b/
The goal here is to have 24 directories, numbered 00 to 23, one for each hour. The images from that hour would then go into that directory. The trouble is the "mv" line - I get this error:
Code:
mv: cannot stat `23*': No such file or directory
What I'm trying to do is something like this:
If I use that on the command line, all files that start with 23 would move to the directory ./23/ - but that doesn't work in the script. What am I doing wrong?