I need to create an apple script to perform DD Commands in sequence, to replicate the same .img file to multiple USB flash drives

The context: the computer is connected to a powered USB hub with 7 usb flash drives connected and unmounted by diskutil. No other USB devices or disk are connected to the computer (so the USB Sticks will be assign a disk1 - disk7 resource mapping)

The steps

  • a file named "source.img" will be prepared and put on the desktop (say an .img of a bootable OS)

  • terminal must be asked to change directory to the desktop

  • with administrative privileges (the password can be inserted into the script, or asked once to the user) it must be asked to perform:

"sudo dd if=source.img of=/dev/rdisk1 bs=1m"

  • the script must wait until the operation is concluded, then ask the terminal to perform another DD, to disk2 this time:

"sudo dd if=source.img of=/dev/rdisk2 bs=1m"

and again, wait until the operation is concluded, and then ask:

"sudo dd if=source.img of=/dev/rdisk3 bs=1m"

and so on with rdisk4, rdisk5, rdisk6, rdisk7.

  • at the end of the disk7 operation , the script can shut down the terminal and send a finder message to the user (or an audio notification) that the USB Duplication process to the 7 flash drives is concluded.

It's a way to create a "USB duplicator on the cheap" for bootable images to be put on multiple sticks, I need it for a school project to my students.

Anybody can help ? I am a zero with Applescript. And this thing will be useful for many.

Thank you ! Alberto

  • You have a good clear specification. Consider posting this job on a service like elance.com where you will attract the attention of available developers. Feb 2, 2014 at 13:24

1 Answer 1


You can do this with a bash script.



dd if=$SOURCE of=/dev/rdisk1 bs=1m
dd if=$SOURCE of=/dev/rdisk2 bs=1m
dd if=$SOURCE of=/dev/rdisk3 bs=1m
dd if=$SOURCE of=/dev/rdisk4 bs=1m
dd if=$SOURCE of=/dev/rdisk5 bs=1m
dd if=$SOURCE of=/dev/rdisk6 bs=1m
dd if=$SOURCE of=/dev/rdisk7 bs=1m

osascript -e 'display notification "Drives complete" with title "Complete!"'

Make the file executable (once):

chmod +x ~/Desktop/script.sh

Run it with administrative privileges:

sudo ~/Desktop/script.sh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .