Learn how to list information about the directories stored in a subversion repository within the CLI.

For many automatization tools, is necessary to retrieve information from your subversion repositories to some things. One of those basic things is the necessity to list all the directories inside the main repository or one of their subfolders. This can be easily done with the svn list instruction and defining the depth to immediates, which lists only the first level of the URL of the given repository:

svn list REPOSITORY_URL -R --depth=immediates

For example, given the following repository with some folders inside, the next command:

svn list svn+ssh://[email protected]/var/www/vhosts/myrepository -R --depth=immediates

Will list all the directory entries of the first level on the console, like the following output:

first_folder/
second_folder/
third_folder/
fourth_folder/

Note that this will happen in the CLI, so you can use it from another programming language, exploding the line-break and receiving an array with the names of the directories. It's worth to say that you can list another levels as well doing this recursively with the --depth argument, this argument instructs Subversion to limit the scope of an operation to a particular tree depth. This argument can have 4 possible values:

  • empty (only the target itself)
  • files (the target and any immediate file children thereof)
  • immediates (the target and any immediate children thereof)
  • infinity (the target and all of its descendants—full recursion).

So for example, if you want to list absolutely all of the directories (and subdirectories) of a path, you could change the argument to infinity:

svn list svn+ssh://[email protected]/var/www/vhosts/myrepository -R --depth=infinity

Happy coding !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors