-------------------------------------------------------------------------------
help for folders
-------------------------------------------------------------------------------

Show names of folders or directories in compact form

folders [folderspec [folderspec [ ... ]]]

Description

folders lists the names of folders or directories in compact form. Hereafter, folder means "folder or directory", regardless of what you or your operating system regard as standard terminology.

With no arguments, folders lists names of folders within the current folder.

Given a folderspec that is a pattern containing ? or *, folders lists names of folders matching that pattern. The pattern may include a prefix indicating a folder that is not the current folder.

Otherwise, given a folderspec that is a folder name, folders lists names of folders contained within that folder.

The list of foldernames is returned in r(folders), so long as that is not empty.

Remarks

The name folders (rather than say dirs) is chosen partly to distinguish this command sharply from the inbuilt Stata command dir.

It is recommended that even if you use Windows, you use forward slashes / rather than backward slashes \. Stata will understand and there will then be no clash with other meanings for the backward slash.

Examples

If you change directory

. cd "`c(sysdir_stata)'"

folders should then return ado as the name of the sole folder within the current folder. If you specify

. folders ado

folders should then return base updates as the names of the folders in that folder. If you specify

. folders ado/base/c* ado/base/d*

folders should then return c d as the names of all the folders satisfying those patterns. If you specify

. folders frog

folders should then return error 601 as no such folder exists.

Acknowledgements

William Gould kindly told me about the subroutine for display in columns, which is copied from the source code for classutil. Kit Baum was a very helpful tester.

Author

Nicholas J. Cox, Durham University, U.K. n.j.cox@durham.ac.uk

Also see

Online: help for dir, help for extended macro functions, help for fs (if installed)