Copy files from incrementally-numbered drives

This code moves through drives (attached via USB) that are numbered incrementally and copies the files on the drives to the local hard disk. I’m using this to more quickly pull the data off of a number of Affectiva Q-Sensors, which I connect to my computer with a USB hub.


#!/bin/bash
for i in {1..20}
do
# Create the directory
mkdir "./sensor_data/${i}"
# Check to see if the volume is mounted
drive="Q${i}"
if mount|grep $drive;
then
echo "${drive} is mounted"
# move the files over to the directory
cp -r /Volumes/${drive}/ ./sensor_data/${i}/
else
echo "${drive} is NOT mounted"
fi
done