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.

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