If I have an ID of an existing project in Synapse, how can I get a list of base folder entities that are in this project? And once I have that, how can I get a list of file/folder entities within one of those folders? ``` proj <- synGet("synXXXXXXX") ...? ```

Created by Ryan Hafen rhafen
Hi Ryan: If you are using the python client there is a convenience function synapseutils.walk that can traverse a heirarchy in Synapse. This function is a generator that in every step returns the path, all of the folders and all of the files in a folder or project. To get the first level you would do: ``` walkedPath = walk(syn, "syn1234") dirpath, dirnames, filenames in walkedPath.next() ``` But it looks like you are using R. In this case you will have to use a query: ``` folders <- synQuery('select id from folder where parentId=="syn1234"') files <- synQuery('select id from file where parentId=="syn1234"') ```

How can I get a list of folders in a project and a list of files in a folder from the R Synapse client? page is loading…