Skip to content

Instantly share code, notes, and snippets.

@rsmoz
Last active February 28, 2016 22:24
Show Gist options
  • Save rsmoz/6ebf704afacf6c81bfd0 to your computer and use it in GitHub Desktop.
Save rsmoz/6ebf704afacf6c81bfd0 to your computer and use it in GitHub Desktop.
Copies a Sample playground from Documents to Desktop and opens it in Xcode. I trigger this from an Alfred workflow.
import shutil, errno, subprocess
def recurse(n):
fileAt = '/Users/rmozayeni/Desktop/Sample%s.playground' % ("" if n == 0 else str(n))
try:
shutil.copytree('/Users/rmozayeni/Documents/Sample.playground', fileAt)
except OSError as e:
if e.errno == errno.EEXIST:
return recurse(n+1)
else: exit(1)
return fileAt
subprocess.call(['open', recurse(0)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment