Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of how to upload a directory hierarchy into a Synapse project
import synapseclient
from synapseclient import Synapse, File, Folder, Project
import os
def upload_recursive(directory, parent):
for item in os.listdir(directory):
if os.path.isdir(os.path.join(directory,item)):
print "%s/" % os.path.basename(item)
folder =, parent=parent))
upload_recursive(directory=os.path.join(directory, item), parent=folder)
print os.path.basename(item)
file1 =,item), parent=parent))
syn = Synapse()
## insert the ID for your project here:
my_project = 'syn2358458'
parent = syn.get(my_project)
upload_recursive('.', parent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment