Use of cp in a script

I am trying to copy files and directories from on flash drive to 5 others, the copy works fine with cp -R but when used in the script it only copies to one of the drives and then finishes the rest of the script without a problem.

#!/bin/sh
#Script to copy files to flash drives
#
quit=n
while test "$quit" = "n"
 do
  echo "Press enter once all drives are inserted..."
  read junk
  cp -R /Volumes/[MasterDrive]/ /Volumes/NO\ NAME/   #NO NAME is default
  cp -R /Volumes/[MasterDrive]/ /Volumes/NO\ NAME1/
  cp -R /Volumes/[MasterDrive]/ /Volumes/NO\ NAME2/
  cp -R /Volumes/[MasterDrive]/ /Volumes/NO\ NAME3/
  cp -R /Volumes/[MasterDrive]/ /Volumes/NO\ NAME4/
  clear
  echo "Copy Completed"
  diskutil rename /Volumes/NO\ NAME [SameNameAsMaster]
  diskutil rename /Volumes/NO\ NAME\ 1 [SameNameAsMaster]
  diskutil rename /Volumes/NO\ NAME\ 2 [SameNameAsMaster]
  diskutil rename /Volumes/NO\ NAME\ 3 [SameNameAsMaster]
  diskutil rename /Volumes/NO\ NAME\ 4 [SameNameAsMaster]
  echo
  echo
  echo
  echo "Data has been copied and drives have been renamed"
  echo "Press "C" and then enter to continue, or press q to quit"
  read choice
  case $choice in
   q) quit=y;;
   c) clear;;
  esac
 done
exit 1

I know my style is not that great and that I could streamline this in any number of ways :slight_smile: but this is what I know and can write in 15-20 minutes, anything else is probably too complicated for my feeble mind.

Any help would be greatly appreciated...

You can start with naming the mounts correctly->

/Volumes/NO\ NAME\ 1/

Your script should check that the flash drives are mounted before it proceeds. You can parse the info from->

mount
1 Like

I think that was it, thanks for the help, it is the little things like that, that trip me up. Stuff you would not realize was wrong just by looking at the man page.:smiley: