Skip to content

Instantly share code, notes, and snippets.

@ruizjme
Last active January 7, 2017 12:58
Show Gist options
  • Save ruizjme/ec8a77b2b9ede69ac79847be69859901 to your computer and use it in GitHub Desktop.
Save ruizjme/ec8a77b2b9ede69ac79847be69859901 to your computer and use it in GitHub Desktop.
Populate usb drives in bulk for a conference giveaway.
#!/usr/bin/env python
import os
import shutil
import time
# DIRECTORY PATHS =========================
driveName = 'DISK_IMG'
drivePath = '../../Volumes/%s' % driveName
folderName = 'EAMSC-files'
folderPath = 'Desktop/%s' % folderName
files = os.listdir(folderPath)
# CHECK IF ISDIR ==========================
while True:
if os.path.isdir(drivePath):
# COPYING ACTION ==================
print '---'
for f in files:
shutil.copyfile('%s/%s' % (folderPath, f),
'%s/%s' % (drivePath, f))
print 'Copied: %s' % f
print '---'
while os.path.isdir(drivePath):
print 'Unplug USB drive.'
time.sleep(5)
else:
print 'Connect USB drive to copy files.'
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment